Data Structures & AlgorithmsVery hardGATE CS · TCS NQT · Product Company SDE

A min-heap is built by inserting 66, 44, 32, 55, 85, 62 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. [44, 55, 62, 66, 85]
  2. B. [32, 55, 44, 66, 85, 62]
  3. C. [62, 55, 44, 66, 85]
  4. D. [55, 66, 44, 62, 85]

Correct answer: A. [44, 55, 62, 66, 85]

Heap after all inserts: [32, 55, 44, 66, 85, 62]. Remove the root (32), move the last element (62) to the root and sift it down to restore the min-heap property, giving [44, 55, 62, 66, 85].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic