Lingo

Heapsort Visualiser

Step through heapify and the repeated root-to-end swaps of heapsort.

Input

Build a max-heap, then swap the root to the end and sift down.

24

Complexity

Operations for n elements.

  • Best O(n log n)
  • Average O(n log n)
  • Worst O(n log n)

Not stable · In place

Array
24
5
8
23
6
2
17
21
20
13
15
12
19
7
14
11
10
18
1
22
4
3
16
9

Build a max-heap, then repeatedly swap the root to the end.

1 / 93
0Comparisons
0Writes
1/93Steps
RunningResult

Heapsort done.