Consider a max heap, represented by the array: 23, 17, 14, 6, 13, 10, 1, 5
Consider a max heap, represented by the array:
23, 17, 14, 6, 13, 10, 1, 5
If a value 20 is inserted into this heap, then what will be the new max heap
Show answerHide answer
Correct answer: (B) 23, 20, 14, 17, 13, 10, 1, 5, 6
Explanation
Add 20 at position 9 as the child of 6, then swap it with 6. Its parent is now 17, so swap again. The parent 23 is larger, so it stops: 23, 20, 14, 17, 13, 10, 1, 5, 6.