CSE221 · Algorithms

Sorting Algorithm Visualizer

Run bubble, selection, insertion, merge and quick sort on the same array and compare their moves.

Compare each neighbouring pair and swap them if they are out of order.

step 1 of 75
comparingwrittenpivotfinal positionoutside current rangegap (value held aside)

Bubble Sort

Repeatedly walks the array swapping out-of-order neighbours, so each pass floats the largest remaining value to the end.

Best
O(n)
Average
O(n²)
Worst
O(n²)
Space
O(1)
Stable
Yes
Comparisons so far
0
Writes so far
0

Input

← → to step, or use the buttons above.