The third sorting algorithm presented in the book is bubble sort. Its way of operation is very simple, because the algorithm just iterates through the array and compares adjacent elements. If they are located in an incorrect order, they are swapped. It sounds very easy, but the algorithm is not very efficient and its usage with large collections could cause performance-related problems.
To better understand how the algorithm works, let's take a look at the following diagram that shows how the algorithm operates in the case of sorting a single-dimensional array with nine elements (-11, 12, -42, 0, 1, 90, 68, 6, -9):
As you can see, ...