Sorting

Bubble Sort

Repeatedly swaps adjacent elements that are out of order.

503182139425764768

Step 1 of 49

Starting Bubble Sort. Repeatedly swap adjacent elements that are out of order.

0
Comparisons
0
Swaps
Algorithm
BubbleSort(arr):
for i = 0 to n−2:
for j = 0 to n−2−i:
if arr[j] > arr[j+1]:
swap arr[j], arr[j+1]
// sorted

Legend

Comparing
Swapping
Sorted
Unsorted
1 / 49Speed