Answered step by step
Verified Expert Solution
Question
1 Approved Answer
p python only IDLE File Edit Format Run Options Window Help 81% . L. Mon 6:28 PM L9 b9L9 mport time import random def sequential
ppython only
IDLE File Edit Format Run Options Window Help 81% . L. Mon 6:28 PM L9 b9L9 mport time import random def sequential search(mylist, number_of trials): lengthlen(mylist) if lengthe return -1 imel time.clockO for count in range(number of trials): if count % length s-0: target mylistE-11 target-mylist[count % length] if targetelement: for element in mylist: break time time.clockO return (time2 timel)number of trials def binary search(mylist, number.of trials) lengthlenCmylist) if length8 return -1 me time.clockO) for count in range(number of trials) if count % length-e: target mylistC-11 1 else: target-mylist[count % length] high len(mylist) 1 while lowhigh: mid -Clow high) 12 if mylist[mid]target elif mylist[mid] target: else: break low mid 1 high mid 1 ime time.clockO return (time2 timel)number of trials def experiment: start list size int (input("Enter start list size:") end listsize-int(inputC"Enter end list size: ")) increment int(input"Enter list size increnent:) seq number of trials int input( Enter nunber of iterations for sequential search:) bin number of trials int inputC'Enter number of iterations For binary search:) for list size in range(start list size, end_list size + 1, increment) mylist O Ln: 1 Col: 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started