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

A max-heap is built by inserting 50, 84, 44, 25, 79, 86 one by one (sift-up on each insert). After one extract-max (move the last element to the root, then sift down), what is the array?

  1. A. [84, 79, 44, 25, 50]
  2. B. [79, 25, 84, 44, 50]
  3. C. [86, 79, 84, 25, 50, 44]
  4. D. [44, 79, 84, 25, 50]

Correct answer: A. [84, 79, 44, 25, 50]

Heap after all inserts: [86, 79, 84, 25, 50, 44]. Remove the root (86), move the last element (44) to the root and sift it down to restore the max-heap property, giving [84, 79, 44, 25, 50].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic