GATE Computer ScienceHardGATE CSE · ISRO

A max-heap is stored in the array [90, 70, 80, 40, 50, 60, 75, 20, 10] (index 0 is the root). After one delete-max operation (the last element is moved to the root and sifted down), what is the array?

  1. A. 80, 70, 75, 40, 50, 60, 10, 20
  2. B. 80, 70, 75, 40, 50, 60, 20, 10
  3. C. 80, 75, 70, 40, 50, 60, 10, 20
  4. D. 70, 50, 80, 40, 10, 60, 75, 20

Correct answer: A. 80, 70, 75, 40, 50, 60, 10, 20

Move 10 to the root and sift down: swap with 80, then with 75. Result: 80, 70, 75, 40, 50, 60, 10, 20.

More Programming and Data Structures (GATE) questions

Exams that ask this topic