Priority Queue
Always hands back the highest-priority item, usually by keeping a binary heap underneath.
Binary Heap: Insert climbs to the root
It reached the root, so it is the smallest value in the heap.
Cost
- Insert
- O(log n)
- Extract top
- O(log n)
- Peek
- O(1)
- Space
- O(n)
Depends on representation. Bounds shown are for a binary heap.
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Binary Heap covers these too, in the same run.