Sorting Algorithm Visualizer
Run bubble, selection, insertion, merge and quick sort on the same array and compare their moves.
38
0
71
1
12
2
95
3
24
4
58
5
6
6
83
7
47
8
30
9
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
Input
← → to step, or use the buttons above.