RK DSA Studio

Min-heap

A complete binary tree whose parent is no greater than either child. Its root is a minimum; the whole array is not sorted.

Remember: Smallest at root; repair along a path.

Example: [1,3,2] is a min-heap; extracting 1 leaves root 2.

Time: O(n) build. Auxiliary space: O(1) extra.

Formula: parent = floor((i − 1) / 2); left = 2i + 1; right = 2i + 2

Zero-based array. The root has no parent; children exist only if their indices are below n. Index lookup: O(1), insert/extract: O(log n), after initial O(n) construction.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.