Following is the given python code for Merge Sort. Dry run all the steps on your register for the following given array and fill the missing blanks in the figure given below If you run the following...



Following is the given python code for Merge Sort. Dry run all the steps on your register for the following given array and fill the missing blanks in the figure given below



If you run the following lines:




random_list_of_nums = [12, 45, 6, 25, 17, 60, 8]




random_list_of_nums = merge_sort(random_list_of_nums) print(random_list_of_nums)



Initial array<br>12<br>45<br>17<br>60<br>8<br>Sorted array<br>25<br>

Extracted text: Initial array 12 45 17 60 8 Sorted array 25
urlul_li.l = [1<br>left list_index = right_list_irdex = 0<br>left list_length, right_list_lengtt - len(left ist), len(-ight_i:t)<br>in sange( Irft list Tengtt + ripht lir-

Extracted text: urlul_li.l = [1 left list_index = right_list_irdex = 0 left list_length, right_list_lengtt - len(left ist), len(-ight_i:t) in sange( Irft list Tengtt + ripht lir- "ength): ir left_1.iruex < lef="" _li:l_luiglh="" and="" right_lil_i="" ndex="">< rigtl_lisl_lerigth: far # we check hich valve froo tre start of eoch (1st ts sna!ler * if the troe at the beginriag of tae left list is enaler, edd it if left_list[left_list_irdex] (= "ight_list[right_list_index]: sortec_list.append!lett_list[le-t_1ist_index]) left 14t 1ndex --i * to the sorted list el sa: rigt_list_index .1 # srw dhe right list elif left_list_index -- -ett_1ist_iength: corted lit.amond r gt+ list[ri+ 1:t inars]} righl_lis_indk += ! # if we'we recched the eed of the of the right list, aid the elererts # frou the lejt list mir righi li-l i neler == rigl lisi iengih: sartad_list amend 1eft_list[left_list_index]) left_-irt_irdex + 1 relurri 0led 1list def merge_sort (nums): # t ihe list is u sinyl.e fiemerii, reiurn il it len(nums) <= 1: return nums # use floor division to get midpoint, indices must be integers mid ten (nums) /! 2 # sort and merge each half left_list merge_sort (nuns[:mid]) right_list = merge_sort(nums[mid:]) # merge the sorted lists into a new one return merge (left_list, right_list) rigtl_lisl_lerigth:="" far="" #="" we="" check="" hich="" valve="" froo="" tre="" start="" of="" eoch="" (1st="" ts="" sna!ler="" *="" if="" the="" troe="" at="" the="" beginriag="" of="" tae="" left="" list="" is="" enaler,="" edd="" it="" if="" left_list[left_list_irdex]="" (="">

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here