GATE 2014 CS (CS2) – Question 22
A max-heap priority queue initially has level order 10,8,5,3,2. Insert 1 then 7. Find the resulting level order.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) 10,8,7,3,2,1,5
Explanation
Append1 at index6; it stays under5. Append7 at index7; it exceeds parent5 and swaps, but remains below10. The level order becomes **10,8,7,3,2,1,5,A**. Heap insertion changes only the ancestor path of the new leaf.