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