Core idea
The algorithm walks through the array many times. On each pass, it compares adjacent values and swaps them if the left value is greater than the right one.
Large values gradually “bubble” to the right edge, so after every pass the last unsorted position becomes fixed.
Bubble Sort is easy to understand, but inefficient on large inputs, which makes it a good teaching example rather than a practical production sort.