HotshardLearn ↗Binary HeapPUSHPOPBUILD

Binary Heap — pick a scenario

0/4 done

Pick one and press Start, then click Next › to step through it.

Watch for

The amber key hopping up one level at a time until it settles just below a key it cannot beat.

More about this scenario
You'll learn

Why an insert costs only O(log n): the new key rises along a single chain of ancestors, never touching the rest of the tree.

How it runs

The key lands in the next free slot, then compares against its parent and swaps upward while it is smaller, stopping when a smaller parent blocks it.