Professional Documents
Culture Documents
Shuttle Sort
What is shuttle sort?
Shuttle sort is an algorithm for sorting numbers into ascending order. You could be asked to trace the algorithm and/or compare how efficient it is.
Example Use shuttle sort to sort 6, 4, 8, 3, 7, 4 into ascending order Pass Start Pass 1 Pass 2 Pass 3 List 6 4 4 4 4 3 Pass 4 Pass 5 3 3 3 3 3 3 Comparisons: 11 Swaps: 8 Same number of swaps, but less comparisons! 4 6 6 6 3 4 4 4 4 4 4 4 8 8 8 3 6 6 6 6 6 6 4 4 3 3 3 8 8 8 7 7 7 4 6 6 7 7 7 7 7 7 8 8 4 7 7 7 4 4 4 4 4 4 4 4 8 8 8 8 Swap 6 and 4 Dont swap 6 and 8 Swap 8 and 3 Swap 6 and 3 Swap 4 and 3 Swap 8 and 7 Dont swap 6 and 7 Swap 8 and 4 Swap 7 and 4 Swap 6 and 4 Dont swap 4 and 4 Notes
Example Use shuttle sort to sort 6, 4, 8, 3, 7, 4 into ascending order Pass Start Pass 1 Pass 2 Pass 3 List 6 4 4 4 4 3 Pass 4 Pass 5 3 3 3 3 3 3 Comparisons: 11 Swaps: 8 Same number of swaps, but less comparisons! 4 6 6 6 3 4 4 4 4 4 4 4 8 8 8 3 6 6 6 6 6 6 4 4 3 3 3 8 8 8 7 7 7 4 6 6 7 7 7 7 7 7 8 8 4 7 7 7 4 4 4 4 4 4 4 4 8 8 8 8 Swap 6 and 4 Dont swap 6 and 8 Swap 8 and 3 Swap 6 and 3 Swap 4 and 3 Swap 8 and 7 Dont swap 6 and 7 Swap 8 and 4 Swap 7 and 4 Swap 6 and 4 Dont swap 4 and 4 Notes
How does this compare to bubble sort with number of comparisons and swaps?
How does this compare to bubble sort with number of comparisons and swaps?