August 2024
Intermediate to advanced
516 pages
11h 47m
English
Let’s walk through a complete example of Bubble Sort.
Assume we want to sort the array [4, 2, 7, 1, 3]. It’s currently out of order, and we want to produce an array that contains the same values in ascending order.
Let’s begin the first pass-through. This is our starting array:

Step 1: First, we compare the 4 and the 2:

Step 2: They’re out of order, so we swap them:

Step 3: Next, we compare the 4 and the 7:
They’re in the correct ...
Read now
Unlock full access