Trees

Heap and priority queue operations with manual step progression

Trees: Heap / Priority Queue

Heap Tree
Pick a heap operation to animate the priority queue.
Backing Array
No values yet.

Heap Behavior

Min Insert appends a value at the end of the array, then bubbles it up until the parent is smaller.

Extract Min removes the root, moves the last value into position, and sifts it down to restore order.

Heapify builds a valid min heap bottom-up from an arbitrary array in linear time.

Compare Min/Max shows the same input reorganized so the smallest value sits at the root of a min heap while the largest value sits at the root of a max heap.

Complexity

Min Insert
Time:O(log n)
Space:O(1)
Extract Min
Time:O(log n)
Space:O(1)
Heapify
Time:O(n)
Space:O(1)
Compare Min/Max
Time:O(n)
Space:O(n)