Quick Sort Learning Lab

Explore divide and conquer, one decision at a time.

1 Choose pivot
—
2 Partition
—
3 Sort sub-arrays
—
4 Combine
Use 2–14 whole numbers.
Current arrayStep 1 of 1
Pivot:—Comparisons:0Swaps:0

1Choose a pivot

Quick Sort begins by selecting one value as the pivot. We will compare the other values with it.

The pivot is a reference point for dividing the array; it is not necessarily the middle value.

Think about it

Which values should go to the left of the pivot?

Use Step to reveal how each comparison is handled.

How the algorithm progresses
  1. Choose a pivot — select a value from the current sub-array.
  2. Partition — move smaller values to one side and larger values to the other.
  3. Recurse — apply Quick Sort to each side independently.
  4. Finish — when sub-arrays have zero or one value, they are already sorted.
Key points
  • Quick Sort is a divide-and-conquer algorithm.
  • Each partition places a pivot into its final sorted position.
  • The order of values on either side may change during partitioning.
  • A poor pivot can lead to unbalanced partitions and slower sorting.
Performance
O(n log n)Average time
O(n²)Worst-case time
O(log n)Typical recursion space

Actual performance depends on pivot choice and the input order. This visualizer uses a teaching-friendly partition method.

Ready. Press Step to begin the first partition.