Visualize Min Heap operations step by step. Watch bubble-up on Insert, sift-down on Extract-Min, and O(1) Peek, with animated tree and array views.
A Min Heap is a complete binary tree where every parent is smaller than its children. The minimum element is always at the root, giving O(1) access to the smallest value.
Every node satisfies: parent ≤ children. Stored as an array: node at index i has children at 2i+1 and 2i+2. Parent of i = floor((i-1)/2). This layout gives O(1) parent/child access.
Append the value at the end, then bubble it up: compare with its parent and swap if the child is smaller. Repeat until the heap property is restored. Time: O(log N).
Move the last element to the root, pop the last slot, then sift down: swap with the smaller child until the heap property is restored. Time: O(log N).
Heap operations are extremely efficient for priority queue workloads.
Min Heap powers Dijkstra, Prim, and any greedy algorithm needing the smallest element fast. Insert a number and watch bubble-up, or Extract to see sift-down in action.