Bubble sort
Bubble sort is an algorithm to order an array by repeatedly scanning it while moving numbers largest than their predecessor by swapping them.
Complexity analysis
- Space complexity
- Time complexity
Pseudocode
Algorithm BubbleSort(a, n)
1: for i := n to 1 do
2: for j := 1 to i - 1 do
3: if a[j] > a[j + 1]
4: t := a[j]; a[j] := a[j + 1]; a[j + 1] := t;
5: return a;