CS Visual Lab
Explore
Learning Paths
5 modules live
Get Started
Heaps & Priority Queues
Module 4.6 — Binary heap with bubble-up/down animation
Type:
Min-Heap
Max-Heap
Preset:
Random
Sorted
Reversed
Small
Insert
Extract min
Clear
Heap Tree
Insert elements or load a preset
Array Representation
Heap Properties
Size
0
Height
0
Root (min)
—
Type
Min-Heap
Time Complexity
Insert
O(log n)
Extract
O(log n)
Peek
O(1)
Heapify
O(n)
Activity Log
Heap initialized. Add elements or load a preset.
How Binary Heaps Work
Insert:
Add at end, bubble up by swapping with parent if heap property violated.
Extract:
Remove root, move last to root, bubble down by swapping with smaller (min) / larger (max) child.
Property:
Every parent ≤ both children.