Presentation is loading. Please wait.

Presentation is loading. Please wait.

6129211937 In the first pass, the first two numbers are compared. The shuttle sort compares the numbers in pairs from left to right exchanging when necessary.

Similar presentations


Presentation on theme: "6129211937 In the first pass, the first two numbers are compared. The shuttle sort compares the numbers in pairs from left to right exchanging when necessary."— Presentation transcript:

1 6129211937 In the first pass, the first two numbers are compared. The shuttle sort compares the numbers in pairs from left to right exchanging when necessary. An additional number is involved in each pass. The 9 is the larger and so the 9 and the 6 are exchanged. 1 st pass Shuttle Sort Example 96 Comparisons:Swaps:11

2 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. Shuttle Sort Example 9126211937 1 st pass Comparisons:Swaps:11 9126211937 2 nd pass 2962 2323

3 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. 3 rd pass Shuttle Sort Example 9126211937 1 st pass 6122911937 2 nd pass 6122911937 Comparisons:Swaps:334

4 The passes continue in the same way. The fourth pass ends here as no swap is needed. Shuttle Sort Example 3 rd pass 9126211937 1 st pass 6122911937 2 nd pass 6122911937 4 th pass 6122911937 Comparisons:Swaps:34 1211 564

5 The fifth pass ends here as no swap is needed. Shuttle Sort Example 3 rd pass 9126211937 1 st pass 6122911937 2 nd pass 6122911937 4 th pass 6112912937 Comparisons:Swaps:64 5 th pass 6112912937 9119 78956

6 Shuttle Sort Example 3 rd pass 9126211937 1 st pass 6122911937 2 nd pass 6122911937 4 th pass 6112912937 5 th pass 6929111237 6 th pass 6929111237 Comparisons:Swaps:96 123113939363 1011121314157891011

7 The list is now sorted. Shuttle Sort Example 3 rd pass 9126211937 1 st pass 6122911937 2 nd pass 6122911937 4 th pass 6112912937 5 th pass 6929111237 6 th pass 3926911127 7 th pass 3926911127 Comparisons:Swaps:1511 1271179797 161718191213141520


Download ppt "6129211937 In the first pass, the first two numbers are compared. The shuttle sort compares the numbers in pairs from left to right exchanging when necessary."

Similar presentations


Ads by Google