#C3230. Bubble Sort

    ID: 46635 Type: Default 1000ms 256MiB

Bubble Sort

Bubble Sort

Implement the Bubble Sort algorithm to sort an array of integers in ascending order. You are not allowed to use any built-in sort functions. The array may contain positive, negative numbers, and zero. The expected time complexity is \(O(n^2)\) in the worst case.

In Bubble Sort, we repeatedly step through the list, compare adjacent elements and swap them if they are in the wrong order. This process is repeated until the list is sorted.

inputFormat

The input consists of two lines. The first line contains a single integer \(n\) (where \(0 \leq n \leq 10^5\)) representing the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

Output the sorted array in ascending order as a sequence of space-separated integers. If the array is empty (i.e., \(n=0\)), output nothing or an empty line.

## sample
0