<DS/>DS_VISUALIZER
FoundationsOOPArraysLinked ListStacksQueuesTreesGraphsHashingStrings
exploreExplore
homechevron_rightTopicschevron_rightTreeschevron_rightHeaps
park

TREES · HEAPS

Heaps

A complete tree in an array — the max always at the root.

Choose an operation

add_boxarrow_outward

Insert

Append at the end, sift up.

O(log n)O(1)◍ 0/6
removearrow_outward

Delete

Take the root; last leaf sifts down.

O(log n)O(1)◍ 0/6
constructionarrow_outward

Heapify

Bottom-up build of a heap — O(n).

O(n)O(1)◍ 0/6
sortarrow_outward

Heap Sort

Extract max n times → sorted.

O(n log n)O(1)◍ 0/6