Bubble Sort

Elementary Sorting Algorithms DSA practice problem on Onlearn.

Difficulty: easy.

Topics: Bubble Sort Algorithm and Its Implementation, Arrays, Time Complexity, Space Complexity, Loops, Conditional Statements, Sorting, Bubble Sort, complexity analysis, sorting algorithms, Bubble Sort, Sorting Algorithms.

Problem Statement Given an array of $N$ integers, sort the array using the Bubble Sorting algorithm. Input Specification The first line contains an integer $N$, the size of the array. The second line contains $N$ space separated integers, representing the elements of the array. Output Specification Output the sorted array with elements separated by spaces. Examples Example 1: Input: Output: Explanation: After sorting, the array becomes 9, 13, 20, 24, 46, 52. Example 2: Input: Output: Explanation: After sorting, the array becomes 1, 2, 3, 4, 5.