#C13022. Bubble Sort Implementation

    ID: 42515 Type: Default 1000ms 256MiB

Bubble Sort Implementation

Bubble Sort Implementation

Given a list of integers, implement the Bubble Sort algorithm to sort the list in ascending order. You are not allowed to use any built-in sorting functions. The bubble sort algorithm repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. This process is repeated until the list is sorted.

The expected time complexity of the algorithm is \(O(n^2)\), where \(n\) is the number of elements in the list. For example, if the input list is:

5
5 4 3 2 1

Then the output should be:

1 2 3 4 5

Input is provided via stdin and output should be printed to stdout. Please ensure your solution handles various edge cases like empty lists, lists with a single element, lists containing duplicate values, and lists with negative numbers.

inputFormat

The first line of input contains an integer \(n\) which represents the number of elements in the list. The second line contains \(n\) space-separated integers representing the elements of the list.

outputFormat

Output the sorted list in ascending order as space-separated integers on a single line.

## sample
5
1 2 3 4 5
1 2 3 4 5