Consider the following sequence of operations on a priority queue (min-heap…

Consider the following sequence of operations on a priority queue (min-heap implementation): Insert(15), Insert(10), Insert(25), Delete(), Insert(5), Delete(). What will be the elements left in the queue (in level-order)?

Answer: A. 15, 25Simulate the min-heap step by step: Insert(15) → Heap = [15] Insert(10) → Heap = [10, 15] Insert(25) → Heap = [10, 15, 25] Delete() removes 10 → Heap = [15,…

  1. A.

    15, 25

  2. B.

    10, 25

  3. C.

    25, 15

  4. D.

    5, 25

Attempted by 198 students.

Show answer & explanation

Correct answer: A

Simulate the min-heap step by step:

  • Insert(15) → Heap = [15]

  • Insert(10) → Heap = [10, 15]

  • Insert(25) → Heap = [10, 15, 25]

  • Delete() removes 10 → Heap = [15, 25]

  • Insert(5) → Heap before reheapify = [15, 25, 5]; after bubbling 5 to root → [5, 25, 15]

  • Delete() removes 5 → Heap = [15, 25]

Final heap elements (level-order): 15, 25

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…