AlgoMotion

Bubble Sort Visualizer

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which means the list is sorted.

5
1
4
2
8
Speed:
Step: 1 / 26
Bubble Sort Details

Current Step:

Initial state of the array.

Pseudocode:

procedure bubbleSort(A : list of sortable items)  n = length(A)  repeat    swapped = false    for i = 1 to n-1 inclusive do      if A[i-1] > A[i] then        swap(A[i-1], A[i])        swapped = true      end if    end for    n = n - 1  until not swappedend procedure