Here we take the first element compare with zeroth element and swap values if the zeroth element is bigger. Now we take the second element. Compare with first one swap values if first one is bigger. Then again we compare the first value again with zeroth and swap if zeroth value is bigger. Like that
we do till end of the array.
Asymptotic Complexity | ||
Something | Time Complexity | Space Complexity |
Worst Case Performance | Swaps: O (n^2) Comparisons : O(n^2) | |
Best Case Performance | Swaps: O (1 ) Comparisons : O(n) | |
Average Case Performance | Swaps: O(n^2) Comparisons : O(n^2) | |
Worst Case space Complexity | Total: O (n) Auxiliary : O(1) |