Playground

Quick Sort

Watch pivot selection, partitioning, and recursive conquest sort the array efficiently.

Quick Sort

Pick a random pivot, partition elements into those smaller and larger, place the pivot in its correct position, then recursively sort both sides.

Time O(n log n) avg  |  Space O(log n)  |  Not Stable  |  In-place
Data
Size10
Speed2000ms
Full Array
38
27
43
3
9
82
10
55
34
76
38
27
43
3
9
82
10
55
34
76
Press SORT to begin

QUICK SORT

quickSort(arr, lo, hi):
if lo >= hi: return
pivot = random element
swap pivot to end
i = lo - 1
for j = lo to hi-1:
if arr[j] <= pivot: i++, swap
place pivot at i+1
quickSort(left of pivot)
quickSort(right of pivot)

Console

n = 10
>Press SORT to begin…