
Chapter 16 Sorting and Searching | 16.9
Pass
[1] [2] [3] [4] [5] [6] [7] [8]
K=1, POS=4 88 44 55 22 99 33 77 66
K=2, POS=6 22 44 55 88 99 33 77 66
K=3, POS=6 22 33 55 88 99 44 77 66
K=4, POS=6 22 33 44 88 99 55 77 66
K=5, POS=8 22 33 44 55 99 88 77 66
K=6, POS=7 22 33 44 55 66 88 77 99
K=7, POS=7 22 33 44 55 66 77 88 99
Sorted array is 22 33 44 55 66 77 88 99
Figure 16.3
Trace of selection sort
Observe that in Figure 16.3 POS gives the smallest among DATA[K], DATA[K+1], ..., DATA[N] during
pass K. e circled elements indicate the elements which are to be swapped. In a similar way all the elements
will be sorted.
Complexity: ...