AlgoScope

Heapify (Build Heap)

AlgorithmintermediateHeap Operations

Sift every parent down, last one first. The whole build costs O(n), not O(n log n).

Decision · step 3 of 12Binary Heap: Build a min heap
1489726current2 > 7

Its left child 2 is smaller, so 7 sinks and 2 takes its place.

Open in the player →or start at step 3

What you will see

Nodes are processed right to left, bottom to top; small subtrees are fixed before large ones.

How binary heap works →

Cost

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

Sum of heights is O(n)not O(n log 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, 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

Leads to

Topics that need this one first.

Taught by the same lesson

Binary Heap covers these too, in the same run.