Binary Heap
A complete tree where every parent outranks its children, stored in a plain array.
Binary Heap: Build a min heap
Take 7, the parent at index 2. Everything below it is already a heap.
Cost
- Insert
- O(log n)
- Extract top
- O(log n)
- Peek
- O(1)
- Build
- O(n)
- Space
- O(n)
Before this
Variants
- Min Heap
- Max Heap
Related
Leads to
Topics that need this one first.
Taught by the same lesson
Binary Heap covers these too, in the same run.