Min Heap
A binary heap whose root is the smallest value.
Binary Heap: Build a min heap
A min heap, in 8 comparisons and 4 swaps. Building costs O(n), not O(n log n).
Cost
- Insert
- O(log n)
- Extract min
- 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.