Baseline sorting visual to introduce comparisons, swaps, and pass optimization.
Easy Explanation
Bubble Sort repeatedly compares neighboring numbers and swaps them until larger values bubble to the end.
Renderer Mode
`Simple` uses abstract, short-form-friendly visuals. `Advanced` keeps the current detailed view.
Pass
n/a
Comparisons
0
Swaps
0
Result
Sorting
Press Play or Step to start execution.
function bubbleSort(values):
n <- length(values)
for pass from 0 to n - 2:
swapped <- false
for i from 0 to n - pass - 2:
if values[i] > values[i + 1]:
swap values[i], values[i + 1]
swapped <- true
if swapped == false:
break
return values