Min Heap
A binary heap whose root is the smallest value.
Decision · step 3 of 12Binary Heap: Build a min heap
Its left child 2 is smaller, so 7 sinks and 2 takes its place.
What you will see
Small values float up; the root is always the smallest.
Cost
| insert | O(log n) |
|---|---|
| extract min | O(log n) |
| peek | O(1) |
| Space | O(n) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.
Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.
Before this
Related
A variant of
Taught by the same lesson
Binary Heap covers these too, in the same run.