Bubble Sort
Steps
- Look at each pair of numbers in the array (e.g.
#1 & #2
,#2 & #3
,#3 & #4
, ... ) - Check if the left element is greater than the right element, if yes, swap!
- After 1st iteration, the last element of the array will be the largest
- Repeat the process n-1 times (n = array length)
Complexity
- Time complexity: $O(n^2)$
- Space complexittL $O(1)$