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

A max-heap is built by inserting 61, 86, 95, 83, 45, 47, 46 one by one. After a single extract-max (move last element to root, sift-down), what is the array?

  1. A. [83, 86, 61, 45, 47, 46]
  2. B. [46, 83, 86, 61, 45, 47]
  3. C. [86, 83, 61, 46, 45, 47]
  4. D. [86, 83, 47, 61, 45, 46]

Correct answer: D. [86, 83, 47, 61, 45, 46]

Heap before = [95, 83, 86, 61, 45, 47, 46]. Remove 95, put 46 at the root and sift down: [86, 83, 47, 61, 45, 46].

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic