50 likes | 297 Views
Decision Maths 1. Sorting Algorithm Shuttle Sort. Compare items 1 and 2; swap them if necessary Compare 2 and 3; swap if necessary; then 1 and 2 again; Compare 3 and 4, then 2 and 3, then 1 and 2; etc. This is an adaption of the Bubble sort, it sorts the sub list fully for each pass.
E N D
Decision Maths 1 Sorting Algorithm Shuttle Sort • Compare items 1 and 2; swap them if necessary • Compare 2 and 3; swap if necessary; then 1 and 2 again; • Compare 3 and 4, then 2 and 3, then 1 and 2; • etc. • This is an adaption of the Bubble sort, it sorts the sub list fully for each pass. A V Ali : www.2july-maths.co.uk
Shuttle Sort 12 5 3 9 5 7 No sort needed 5 12 3 9 Pass 1 5 7
5 12 3 9 Sort needed 5 7 No sort needed 7 12 3 9 5 5 Pass 2
Pass 4 7 12 3 9 No sort needed 5 5 Sort needed 7 12 3 9 5 5 Sort needed 7 3 12 9 5 5 Pass 5 Sort needed 3 7 12 9 5 5 Sort needed 5 7 12 9 5 3
Sort needed 5 7 12 9 3 5 5 7 9 12 No sort needed 3 5 Pass 6 5 7 9 12 3 5 Sorted !!