Consider a max heap, represented by the array 400, 300, 200, 100, 150, 160, 170, 80, 40. Which will be the new heap after insertion of 350?
Show answerHide answer
Correct answer: (B) 400, 350, 200, 100, 300, 160, 170, 80, 40, 150
Explanation
Insert 350 at the end (position 10). Its parent 150 is smaller, so swap. The new parent 300 is smaller, so swap again. 400 is larger, so stop: 400, 350, 200, 100, 300, 160, 170, 80, 40, 150.