selection sort' select function def select(seqstart)minindex start for in range(start+ len(seq))if seq[minindexseq[ ]minindex return minindex the start argument tells the select function where to start looking for the smallest item it searches from start to the end of the sequence for the smallest item the selection sort algorithm works by finding the smallest item using the select function and placing that item into the first position of the sequence now the value in the first position must be put someplace else it is simply swapped with the location of the value that is being moved the algorithm proceeds by next looking for the second smallest value in the sequence since the smallest value is now in the first location in the sequencethe selection sort algorithm starts looking from the second position in the list for the smallest value when the smallest value is found (which is really the second smallest value for the listthe value in the second position and this value are swapped then the selection sort algorithm looks for the smallest item starting at the third location in the sequence this pattern repeats until all the items in the sequence have been sorted the selsort function does the actual sorting for the algorithm the selection sort code def selsort(seq)for in range(len(seq)- )minindex select(seqitmp seq[iseq[iseq[minindexseq[minindextmp we can visualize the selection sort algorithm by running an animation of it sorting the animation is pictured in fig having sorted more than half the values in sequence the green dots represent items that are now in their proper location in the sequence the height of the dot from the -axis ( the -valueis its value the -axis is the position in the list in this animation all the values between and are being sorted into ascending order the upper-right corner represents those values that have not yet been sorted the algorithm starts looking for the next smallest value just to the right of the green diagonal line it finds the minimum value ( closest to the -axisby going through all the remaining unsorted dots once it finds the smallshortest dotit swaps it with the left-most dot to put it into is sorted position in the list the complete code for this animation is given in sect and can be downloaded from the website accompanying this text try it outthis copy belongs to 'acha