select the first element as the minimumNumber in the unsorted array , compare it with second element, if it smaller then the minimumNumber then swap with it, if not move to another element and check same for it, repeat it till n-1 elements of the array.
- Time Complexity : O(n^2)
- Space Complexity : O(1)
Repeatedly compare the adjacent elements ,if arr[j]>arr[j+1] swap them. The maximum element bubbles up to the end of the unsorted array after each iteration. After n-1 iterations, we get sorted array.
- Time Complexity : O(n^2)
- Space Complexity : O(1)