Question: I need some help with this code in python3. There is a function below for a sequnetial search, a binary search and a list.. The
I need some help with this code in python3. There is a function below for a sequnetial search, a binary search and a list.. The binary search is missing its sorthing part. I need help completing the binary search and and for each size value in the list complete: 1) generate that number of random integer values (from 1 to 1000,0000) in a list 2) run a sequential search of -1 and track the time 3) sort the list using .sort() method 4) run a binary search of -1 on the sorted list, and record the time of sorting and binary search """ def sequentialSearch(alist, item): pos = 0 found = False while pos < len(alist) and not found: if alist[pos] == item: found = True else: pos = pos + 1 return found def binSearch(list, target): return binSearchHelper(list, target, 0, len(list) - 1) def binSearchHelper(list, target, left, right): if left > right: return False middle = (left + right)//2 if list[middle] == target: return True elif list[middle] > target: return binSearchHelper(list, target, left, middle - 1) else: return binSearchHelper(list, target, middle + 1, right) import random import time list_sizes = [10,100,1000,10000,100000,1000000]
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
