Question: (a) Suppose we are performing a binary search on a sorted list called numbers initialized as follows: # index 0 1 2 3 numbers
(a) Suppose we are performing a binary search on a sorted list called numbers initialized as follows: # index 0 1 2 3 numbers [-2, 0, 1, 7, 4 5 6 7 8 9 10 11 12 13 9, 16, 19, 28, 31, 40, 52, 68, 85, 99] #search for the value 5 index= binary_search (numbers, 5) Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm's code) and write the value that would be returned from the search. Assume that we are using the binary search algorithm shown in lecture and section. Indexes examined: Value Returned: (b) Write the state of the elements of the list below after each of the first 3 passes of the outermost loop of the selection sort algorithm. numbers = [63, 9, 45, 72, 27, 18, 54, 36] selection_sort (numbers) (c) Trace the complete execution of the merge sort algorithm when called on the list below, similarly to the example trace of merge sort shown in the lecture slides. Show the sub-lists that are created by the algorithm and show the merging of sub-lists into larger sorted lists. numbers [63, 9, 45, 72, 27, 18, 54, 36] merge_sort (numbers)
Step by Step Solution
3.45 Rating (155 Votes )
There are 3 Steps involved in it
The detailed ... View full answer
Get step-by-step solutions from verified subject matter experts
