Guided lesson

Heaps and Priority Queues

Trees

Heaps and Priority Queues

Core

Mental model

  • Peek is O(1).

Operations

peek O(1)

Cost shape

Push/pop O(log n), peek O(1)

Watch out

Expecting the whole heap array to be sorted.

Related algorithms

Heap SortDijkstra Shortest Path
Guided progression
10% lesson
Step 1 / 2Learner goal
Speech settings Speed 1.0 · Volume 90%

Keyboard: Space play/pause · Arrow keys step · Page Up/Down change sections · R restart