notice that bottom stops at the second to last item in the list once all of the items up to the last have been put in the proper placethe last item has to be the largestso there is no need to bother looking at it the selection sort algorithm is easy to write and works well for moderate-sized listsbut it is not very efficient sorting algorithm we'll come back and analyze it after we've developed another algorithm divide and conquermerge sort as discussed aboveone technique that often works for developing efficient algorithms is the divideand-conquer approach suppose friend and were working together trying to put our deck of cards in order we could divide the problem up by splitting the deck of cards in half with one of us sorting each of the halves then we just need to figure out way of combining the two sorted stacks the process of combining two sorted lists into single sorted result is called merging the basic outline of our divide and conquer algorithmcalled mergesort looks like thisalgorithmmergesort nums split nums into two halves sort the first half sort the second half merge the two sorted halves back into nums the first step in the algorithm is simplewe can just use list slicing to handle that the last step is to merge the lists together if you think about itmerging is pretty simple let' go back to our card stack example to flesh out the details since our two stacks are sortedeach has its smallest value on top whichever of the top values is the smallest will be the first item in the merged list once the smaller value is removedwe can look at the tops of the stacks againand whichever top card is smaller will be the next item in the list we just continue this process of placing the smaller of the two top values into the big list until one of the stacks runs out at that pointwe finish out the list with the cards from the remaining stack here is python implementation of the merge process in this codelst and lst are the smaller lists and lst is the larger list where the results are placed in order for the merging process to workthe length of lst must be equal to the sum of the lengths of lst and lst you should be able to follow this code by studying the accompanying commentsdef merge(lst lst lst )merge sorted lists lst and lst into lst these indexes keep track of current position in each list all start at the front len(lst )len(lst