on the second iteration of the for loopsearch_index will have the value which is the index of the third element in the array at this pointwe start our comparison in the direction to the left (towards index will be compared with but because is greater than the while loop will not be executed will be replaced by itself because the search_index variable never got decremented as suchunsorted_list[search_indexinsert_value will have no effect when search_index is pointing at index we compare with and move to where is stored we then compare with and move to where was initially stored at this pointthe while loop will break and will be stored in index the array will be partially sorted with the values [ the preceding step will occur one last time for the list to be sorted the insertion sort algorithm is considered stable in that it does not change the relative order of elements that have equal keys it also only requires no more memory than what is consumed by the list because it does the swapping in-place its worst case value is ( and its best case is (nselection sort another popular sorting algorithm is the selection sort this sorting algorithm is simple to understandyet also inefficientwith its worst and best asymptotic values being ( it begins by finding the smallest element in an array and interchanging it with data atfor instancearray index [ the same operation is done second timehoweverthe smallest element in the remainder of the list after finding the first smallest element is interchanged with the data at index [ in bid to throw more light on how the algorithm workslets sort list of numbersstarting at index we search for the smallest item in the list that exists between index and the index of the last element when this element has been foundit is exchanged with the data found at index we simply repeat this process until the list becomes sorted