end end straightselection analysis of straight selection evidentlythe number of key comparisons is independent of the initial order of keys in this sensethis method may be said to behave less naturally than straight insertion we obtain ( )/ the number of moves is at least mmin *( in the case of initially ordered keys and at most mmax / *( )if initially the keys are in reverse order in order to determine mavg we make the following deliberationsthe algorithm scans the arraycomparing each element with the minimal value so far detected andif smaller than that minimumperforms an assignment the probability that the second element is less than the firstis / this is also the probability for new assignment to the minimum the chance for the third element to be less than the first two is / and the chance of the fourth to be the smallest is / and so on therefore the total expected number of moves is hn- where hn is the -th harmonic number hn / / / hn can be expressed as hn ln(ng / / where is euler' constant for sufficiently large nwe may ignore the fractional terms and therefore approximate the average number of assignments in the -th pass as fi ln(ig the average number of moves mavg in selection sort is then the sum of fi with ranging from to nmavg *( + (si < <nln( )by further approximating the sum of discrete terms by the integral integral ( :nln(xdx ln(nn we obtain an approximate value mavg (ln(ngwe may conclude that in general the algorithm of straight selection is to be preferred over straight insertionalthough in the cases in which keys are initially sorted or almost sortedstraight insertion is still somewhat faster sorting by straight exchange the classification of sorting method is seldom entirely clear-cut both previously discussed methods can also be viewed as exchange sorts in this sectionhoweverwe present method in which the exchange of two items is the dominant characteristic of the process the subsequent algorithm of straight exchanging is based on the principle of comparing and exchanging pairs of adjacent items until all items are sorted as in the previous methods of straight selectionwe make repeated passes over the arrayeach time sifting the least item of the remaining set to the left end of the array iffor changewe view the array to be in vertical instead of horizontal positionand with the help of some imagination the items as bubbles in water tank with weights according to their keysthen each pass over the array results in the