#K74002. Bubble Sort Implementation
Bubble Sort Implementation
Bubble Sort Implementation
In this problem, you are required to implement the Bubble Sort algorithm to sort a list of integers in ascending order. Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The algorithm stops when no more swaps are needed.
The time complexity of Bubble Sort is \(O(n^2)\) in the worst case, where \(n\) is the number of elements. Your task is to read the input from standard input, perform a bubble sort on the list, and print the sorted list to standard output.
inputFormat
The first line of input contains an integer (n), the number of elements in the list. The second line contains (n) space-separated integers.
outputFormat
Output a single line containing the (n) sorted integers in ascending order, separated by spaces.## sample
5
64 34 25 12 22
12 22 25 34 64