GATE Computer ScienceModerateGATE CSE · ISRO

Keys 12, 7, 19, 3, 25, 9, 14 are inserted one by one into an initially empty max-heap stored in an array (index 0 is the root), each insertion sifting up. What is the final array?

  1. A. 25, 12, 19, 3, 7, 9, 14
  2. B. 25, 19, 12, 7, 3, 14, 9
  3. C. 25, 19, 14, 12, 3, 7, 9
  4. D. 25, 19, 14, 3, 7, 9, 12

Correct answer: D. 25, 19, 14, 3, 7, 9, 12

Inserting and sifting up gives the array 25, 19, 14, 3, 7, 9, 12.

More Programming and Data Structures (GATE) questions

Exams that ask this topic