Ss 2
Ss 2
The bubble sort is a good starting point since it is one of the simplest sorting algorithms. It's
mostly just good for teaching purposes though since it is one of the slowest sorting
algorithms.
In short, the bubble sort algorithm compares every two adjacent values and swaps them if
the first one is bigger than the second one. This reflects its name since the values tend to
move up into the correct order, like bubbles rising to the surface.
Note that the solution I provided is a slightly improved version of the usual bubble sort
algorithm since we are subtracting the number of passes from the inner loop to avoid
unnecessary comparisons. To get a better understanding of what's actually happening, here is
a diagram with an example: