Heap sort
Heap sort · O(n log n)
Elements Active CompletePlayed 0.0 s · same input
Heap sort
Heap sortOperations0
Comparisons0
Writes0
Each comparison or write counts as 1 operation. Playback time is not execution time.
← Back to six-algorithm comparisonHow it works +
Build a max heap with the largest value at the top. Swap it to the end, repair the remaining heap and repeat until every element is in place.
Extra space: O(1); Unstable. Each comparison or main-array write counts as 1 operation.