AlgoScope

Extract Min / Max

AlgorithmintermediateHeap Operations

Take the root, move the last leaf up into it, then let that value sink.

Decision · step 3 of 5Binary Heap: Extract the minimum
734286current2 > 6

Its right child 2 is smaller, so 6 sinks and 2 takes its place.

Open in the player →or start at step 3

What you will see

The root leaves; the last leaf jumps to the top and sinks to its place.

How binary heap works →

Cost

BestO(log n)
AverageO(log n)
WorstO(log n)
SpaceO(1)

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, predict what happens next, try operations in any order.

Screen readers: Nodes announce value, parent and children; each step announces the comparison and whether the value moves up or down.

Reduced motion: Swaps become value crossfades in both the tree and the array view.

Before this

Variants

  • Extract Min Min heap.
  • Extract Max Max heap.

Leads to

Topics that need this one first.

Taught by the same lesson

Binary Heap covers these too, in the same run.