sequences fig selection sort snapshot consider sorting the list [ as depicted in fig after each call of the select function from the selsort function the next element of the list is placed in its final location sorting the list leads to the intermediate steps as shown each time the select function is called the new smallest element is swapped with the first location in the rest of the list to move the next smallest element into its location within the sorted list to find each new smallest element we call select which must run through the rest of the list looking for the minimum element after each pass the list in fig is one item closer to sorting the whole list it turns out that this early attempt at writing sorting algorithm is not that great the complexity of this algorithm is ( because each time through the for loop in the selsort function we call the select function which has its own for loop the for loop is executed times and each time it is executed the for loop must go through one less item looking for the smallest value that is left to be sorted sothe first time we execute the body of the for loop timesthen times the second time select is calledthen times and so on we have seen this pattern before the sum of the first integers has an term in its formula thereforeselection sort is ( this means as we try to sort some larger lists the algorithm will really start to slow down you should never use this algorithm for sorting even on small lists we can do much better this copy belongs to 'acha