Bubble Sort Algorithm
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. This process is repeated until the list is sorted.
Algorithm
1. Compare the first two adjacent elements.
2. If the first element is greater than the second, swap them.
3. Move to the next pair of adjacent elements and repeat the
process.
4. Continue until the end of the list is reached.
5. Repeat the process for the entire list until no swaps are needed.
Time Complexity
Best Case: O(n)
Average Case: O(n²)
Worst Case: O(n²)