About Bubble Sort
Bubble Sort is one of the simplest sorting algorithms. It works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they're in the wrong order. This process continues until no more swaps are needed.
Core Concepts
- Comparison-based: Compares adjacent pairs of elements
- In-place: Requires O(1) additional space
- Stable: Maintains relative order of equal elements
- Time Complexity: O(n²) in worst and average cases, O(n) in best case
- Best for: Small datasets or nearly sorted data
The name "bubble sort" comes from the way larger elements "bubble" to the end of the array with each pass through the data.