This Java project implements the Bubble Sort algorithm, one of the simplest sorting techniques. The program sorts an array of integers by repeatedly stepping through the list, comparing adjacent elements, and swapping them if they are in the wrong order. The sorting process continues until the array is completely sorted.
Written by Mohammed Qutu on 03/03/2024.
- Java 21.0.2 or later
To run the program, compile the BubbleSort.java file and execute it. The program will print the sorted array to the console after performing the sorting operation.
2 3 5 8 9
- Compare each pair of adjacent elements.
- If the first element is greater than the second, swap them.
- Continue through the array until no more swaps are needed.
- The array is now sorted.
- The
whileloop continues until no more swaps are needed. - The
forloop iterates through the array and compares adjacent elements. - The
swapvariable is used to keep track of whether any swaps have been made during the iteration.
This project is licensed under the MIT License - see the LICENSE file for details.