← Back to All Algorithms
🔺 Heapsort
How It Works
Build Max-Heap:
Convert array to max-heap (O(n))
Extract Max:
Swap root with last element, reduce heap size
Heapify:
Restore heap property by sifting down
Repeat until heap is empty
Phase: Build Heap
Click "Start" to begin Heapsort
Reset
▶ Start
Step →
Complexity
Time:
O(n log n) — always
Space:
O(1) — in-place
Not Stable