Data Structures & AlgorithmsVery hardGATE CS · ICPC regional · Product Company SDE

A max-heap is built by inserting 23, 22, 90, 96, 49, 39, 36 one by one. After a single extract-max (move last element to root, sift-down), what is the array?

  1. A. [90, 49, 39, 22, 36, 23]
  2. B. [90, 49, 39, 22, 23, 36]
  3. C. [36, 90, 39, 22, 49, 23]
  4. D. [90, 39, 22, 49, 23, 36]

Correct answer: A. [90, 49, 39, 22, 36, 23]

Heap before = [96, 90, 39, 22, 49, 23, 36]. Remove 96, put 36 at the root and sift down: [90, 49, 39, 22, 36, 23].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic