#K65052. Modified Bubble Sort
Modified Bubble Sort
Modified Bubble Sort
You are given an array of n integers. Your task is to sort the array in non-decreasing order using a modified bubble sort algorithm. In this algorithm, adjacent elements are compared and swapped if they are in the wrong order until no more swaps are needed. The algorithm continues until the array is fully sorted.
The worst-case time complexity of bubble sort is given by \(\mathcal{O}(n^2)\).
Note: The input and output are handled via standard input (stdin) and standard output (stdout) respectively.
inputFormat
The first line contains an integer n representing the number of elements in the array.
The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output the sorted array as a sequence of space-separated integers in non-decreasing order.
## sample5
5 3 8 6 2
2 3 5 6 8