Consider a binary max-heap implemented using an array.What is the content of…

2009

Consider a binary max-heap implemented using an array.What is the content of the array after two delete operations on {25,14,16,13,10,8,12}

  1. A.

    14,13,12,10,8

  2. B.

    14,12,13,8,10

  3. C.

    14,13,8,12,10

  4. D.

    14,13,12,8,10

Attempted by 178 students.

Show answer & explanation

Correct answer: D

Final array after two deletions: [14, 13, 12, 10, 8]

  • Step 1: Start with the original array given in the previous question: [14, 13, 12, 11, 10, 9, 8].

  • Step 2: Perform the two delete operations indicated by the previous answer. Those deletions remove the values 11 and 9 from the array.

  • Step 3: After removing 11 and 9, the remaining elements in their original relative order are [14, 13, 12, 10, 8].

  • Check: Deletion removes elements but does not reorder the others; that is why the final sequence preserves the original order of the remaining values.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir