Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

A min-heap is built by inserting 60, 47, 76, 55, 61, 80, 34 one by one (sift-up on each insert). After one extract-min (move the last element to the root, then sift down), what is the array?

  1. A. [47, 55, 76, 60, 61, 80]
  2. B. [34, 55, 47, 60, 61, 80, 76]
  3. C. [76, 55, 47, 60, 61, 80]
  4. D. [55, 60, 47, 76, 61, 80]

Correct answer: A. [47, 55, 76, 60, 61, 80]

Heap after all inserts: [34, 55, 47, 60, 61, 80, 76]. Remove the root (34), move the last element (76) to the root and sift it down to restore the min-heap property, giving [47, 55, 76, 60, 61, 80].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic