#K60262. Bubble Sort and Test Case Processing
Bubble Sort and Test Case Processing
Bubble Sort and Test Case Processing
This problem requires you to implement the bubble sort algorithm and process multiple test cases using it. You are given an array of integers for each test case, and you need to sort the array in non-decreasing order using the bubble sort algorithm. The bubble sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. In each pass through the array, the largest unsorted element "bubbles" up to its correct position. Mathematically, the comparison and swap operation can be thought as:
\( \text{if } a[j] > a[j+1] \text{ then swap } a[j] \text{ and } a[j+1] \)
After sorting the array, output the sorted array.
inputFormat
The first line of input contains a single integer \(T\) (\(T \geq 1\)), representing the number of test cases. Each test case consists of two lines:
- The first line contains an integer \(N\) (the number of elements in the array).
- The second line contains \(N\) space-separated integers.
All input should be read from stdin.
outputFormat
For each test case, output the sorted array in non-decreasing order on a separate line. The integers in each array should be separated by a single space. All output should be written to stdout.
## sample1
5
64 25 12 22 11
11 12 22 25 64