Sift Down
Swap with the better child while a child outranks the value. One path, O(log n).
Binary Heap: Extract the minimum
Its right child 2 is smaller, so 6 sinks and 2 takes its place.
Cost
- Best
- O(1)
- Average
- O(log n)
- Worst
- O(log n)
- Space
- O(1)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Binary Heap covers these too, in the same run.