Max Heap
A binary heap whose root is the largest value.
Binary Heap: Build a max heap
Its left child 7 is larger, so 2 sinks and 7 takes its place.
Cost
- Insert
- O(log n)
- Extract max
- O(log n)
- Peek
- O(1)
- Space
- O(n)
Before this
Related
A variant of
Taught by the same lesson
Binary Heap covers these too, in the same run.