Quick Sort Explorer

Watch a pivot split the array into a smaller group and a larger group, then repeat on each side, with every move narrated in plain English. Change the pivot rule to see the same input sort in n log n steps or slow to n squared.

This interactive quick sort visualization shows the divide-and-conquer sorting algorithm one move at a time, with every step narrated in plain English, so a first-time learner can see exactly what happens and why the choice of pivot decides whether quick sort is fast or slow. Quick sort works by picking one value as the pivot, rearranging the section so that every smaller value ends up on its left and every larger value on its right, then repeating the same idea on each side. When the pivot lands near the middle, each side is about half the size of the parent, and the whole array sorts in roughly n log n steps.

Press play, or step through the animation one comparison, move, or partition at a time. Each value sits in its own numbered box, and the boxes slide as values are swapped, so you can literally watch smaller values move into the left group and larger ones stay on the right. The pivot is drawn in violet and moved aside so the scan can pass over it. Two pointers, i and j, sweep across the section: j checks each value against the pivot, and i marks the boundary of the smaller-than-pivot region, which is shaded and captioned so you can watch it grow. When the scan finishes, the pivot drops into the gap between the two groups, turns green, and is locked in its final sorted position forever. A plain-language line under the array explains the current move as it happens, a phase label shows whether you are picking a pivot, partitioning, or locking one in place, and a progress bar tracks how many values are already in their final spot.

Use the pivot rule control and the presets to make the lesson concrete. On an already sorted array, choosing the first or last element as the pivot peels off a single value each time, the recursion depth grows to n, and the comparisons count climbs all the way to the worst case of n times n minus one over two. Switch the same input to the median-of-three rule and the array sorts quickly again, with a shallow recursion depth close to log n and a far smaller comparison count. Try the reversed and many-duplicates presets to explore the other behaviors that make pivot choice the heart of quick sort.