6 12 9 2 11 3 7 6 9 Shuttle Sort Example 1st pass Comparisons: 1 The shuttle sort compares the numbers in pairs from left to right exchanging when necessary. An additional number is involved in each pass. In the first pass, the first two numbers are compared. The 9 is the larger and so the 9 and the 6 are exchanged. Comparisons: 1 Swaps: 1
9 12 6 2 11 3 7 2 9 12 6 2 11 3 7 6 2 9 Shuttle Sort Example 1st pass 2nd pass In the second pass, the first three numbers are involved. The second and third numbers are compared, and swapped if necessary. Then the first and second numbers are compared, and swapped if necessary. Comparisons: 2 3 1 Swaps: 3 2 1
Shuttle Sort Example 1st pass 9 12 6 2 11 3 7 6 12 2 9 11 3 7 2nd pass 6 12 2 9 11 3 7 3rd pass In the third pass, the third and fourth numbers are compared, and swapped if necessary. No swap is needed in this case, so the third pass ends here. Comparisons: 4 3 Swaps: 3
Shuttle Sort Example 1st pass 9 12 6 2 11 3 7 6 12 2 9 11 3 7 2nd pass 6 12 2 9 11 3 7 3rd pass 6 12 2 9 11 3 7 11 12 4th pass The passes continue in the same way. The fourth pass ends here as no swap is needed. Comparisons: 6 5 4 Swaps: 4 3
Shuttle Sort Example 1st pass 9 12 6 2 11 3 7 6 12 2 9 11 3 7 2nd pass 6 12 2 9 11 3 7 3rd pass 6 11 2 9 12 3 7 4th pass 6 11 2 9 12 3 7 9 9 11 12 5th pass The fifth pass ends here as no swap is needed. Comparisons: 8 7 9 6 Swaps: 6 5 4
Shuttle Sort Example 1st pass 9 12 6 2 11 3 7 6 12 2 9 11 3 7 2nd pass 6 12 2 9 11 3 7 3rd pass 6 11 2 9 12 3 7 4th pass 6 9 2 11 12 3 7 5th pass 6 9 2 11 12 3 7 3 3 6 3 9 3 9 3 11 12 6th pass Comparisons: 12 14 15 13 11 10 9 Swaps: 10 11 9 7 6 8
Shuttle Sort Example 1st pass 9 12 6 2 11 3 7 6 12 2 9 11 3 7 2nd pass 6 12 2 9 11 3 7 3rd pass 6 11 2 9 12 3 7 4th pass 6 9 2 11 12 3 7 5th pass 3 9 2 6 11 12 7 6th pass 3 9 2 6 11 12 7 7 7 9 9 7 11 7 12 7th pass The list is now sorted. Comparisons: 18 17 20 19 15 16 Swaps: 14 15 13 11 12