Heap Insert
Drop the value in the next free slot, then let it climb until its parent outranks it.
Binary Heap: Insert climbs to the root
1 goes into the next free slot, index 6. That keeps the tree complete, but it is probably in the wrong 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.