Bubble Sort
Bubble Sort is a simple sorting algorithm that works by repeatedly stepping through a list of items, comparing adjacent pairs, and swapping them if they are in the wrong order. Here's how it works in simple terms:
- Start at the beginning: Look at the first two items in the list.
- Compare: If the first item is greater than the second item, swap them.
- Move to the next pair: Move one position to the right and compare the next two items.
- Repeat: Continue this process for the entire list. After one complete pass, the largest item will "bubble up" to the end of the list.
- Repeat the process: Go back to the start of the list and repeat the steps, ignoring the last sorted items (since they are already in place).
- Finish when sorted: Keep repeating until you make a pass without any swaps, which means the list is sorted.