Bubble sorting example

Comparing pairwise, the largest number floats to the end in each round.
For example:

9 3 1 4 2 7 8 6 5 Number of exchanges
first round 3 1 4 2 7 8 6 5 9 8
second round 1 3 2 4 7 6 5 8 9 4
Third round 1 2 3 4 6 5 7 8 9 3
Fourth round 1 2 3 4 5 6 7 8 9 1

Guess you like

Origin blog.csdn.net/qq_46620129/article/details/113798073