Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedpimage text in transcribedimage text in transcribedpython 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: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago