Algorithm visualizer
Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Build a max-heap inside the array, then repeatedly move the largest value to the end and restore the heap on the rest.
Sort [1, 2, 3, 4, 5, 6, 7]. Which value is swapped into its final place first, and why is it that value?
Step 1 of 54
Build a max-heap: sift down the node at index 3.