Bubble Sort

Bubble sort is a simple sorting algorithm that works by repeatedly swapping adjacent elements if they are in the wrong order.

On each pass of the array, the smallest element is moved to the left, and as such each element is bubbled down to the bottom. There is also an alternative version of bubble sort known as bubble up where the largest element is moved up to the right.

Bubble sort is a very slow sort algorithm due to needing n comparisons for each pass and there is up to n passes needed. Thus the time complexity is O(n^2).

The red line represents where the sorting algorithm is up to, so everything to the left is sorted.

Settings