← All Tools

Binary Heap Visualizer

A binary heap is a complete binary tree where every parent obeys a heap property (min-heap: parent ≤ children; max-heap: parent ≥ children). Watch each sift-up and sift-down step by step, on the tree and the backing array.

Size 0 Height 0 Root Last operation

Backing array

A heap of size n lives in an array where the children of index i are at 2i+1 and 2i+2, and the parent is at ⌊(i-1)/2⌋. No pointers, no allocations per node.

Bulk heapify

Paste comma-separated values and run Floyd's O(n) build-heap — sift-down starting from the last internal node down to the root.

Step log

Complexity cheat sheet

peek — O(1). The extreme is always at index 0.

insert / decrease-key — O(log n). Add at the end, sift up.

extract-root / delete-key — O(log n). Move last to root, sift down.

build-heap — O(n) with Floyd's method (sift-down from ⌊n/2⌋-1 to 0), not O(n log n).

heap-sort — O(n log n), in-place, unstable.