← Quiz: Heaps and Heap Sort Internals: all 15 questions
Quiz: Heaps and Heap Sort Internals · Question 4 of 15
A new value is pushed onto a min-heap. Where is it placed first, and which way does it move?
A new value is pushed onto a min-heap. Where is it placed first, and which way does it move?
- A.At the root, then it sifts down
- B.In sorted position, by binary search
- C.At the end of the array, then it sifts up while it is smaller than its parent
- D.At the end, and it never moves
Answer & explanation
Correct answer: At the end of the array, then it sifts up while it is smaller than its parent
Adding at the end keeps the tree complete; sifting up restores the parent ≤ child rule in O(log n).
Can you get the rest right without peeking?
Take the timed Quiz: Heaps and Heap Sort Internals quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →