⚡ AlgoZen_
~/home/sorting_algorithms/heap_sort6 / 7

Heap Sort

Intermediate

Build a max-heap from the array, then repeatedly extract the maximum element and place it at the end. Achieves optimal O(n log n) time with O(1) extra space — no recursion stack needed.

time:O(n log n)
space:O(1)
⚡ +200_XP
step[1/41]
> Start
4
10
3
5
1
8
7
Heap Sort: first build a Max Heap, then extract the maximum element repeatedly.

// tap NEXT STEP to walk through one step at a time