Question: Above file contains implementation of sequential search and binary search. You will use the program to compare the performance of these two search techniques. Run

Above file contains implementation of sequential search and binary search. You will use the program to compare the performance of these two search techniques.
Run the code few times and see what is going on. The program determines the execution times for binary search and sequential search for different list sizes.
Evaluate the algorithm. After starting the program give the values as in the following interactions.
Enter start list size: 100000
Enter end list size: 200000
Enter list size increment: 10000
Enter number of iterations for sequential search: 100
Enter number of items for binary search: 1000
1) Why would you run binary search many more times than sequential search?
2) Do some more evaluations to investigate the following issues.
a) how do the execution times for the two algorithms compare for "small" lists?
b) what happens to the execution time of sequential search as the list size grows?
c) what happens to the execution time of binary search as the list size grows?
d) how do the execution times for the two algorithms compare for "large" lists?
3) show supporting results for the answers to the above questions.
4) which algorithm would you employ for "small"lists? Would your answer change if the number of queries varies?
5) which algorithm would you employ for "large" lists? Would your answer change if the number of queries varies?
6) why do the two algorithms exhibit their respective behaviors?
 Above file contains implementation of sequential search and binary search. You
will use the program to compare the performance of these two search

File Edit Format Run Options Window Help import time import random def sequantial search (mylist, number_of trials): length- 1en (mylist) if length =-0: return -1 time1 = time . clock ( ) for count in range (number of trials): if count % length 0: else: for element in mylist: target mylist [-1] + 1 target =mylist [count % length] if target element: break time2 time. clock ( ) return (time2 timel) / number of trials length = len (mylist) def binary search (mylist, number of trials): length 0: burn -1 time1-time.clock ( tor count in range (number of trials): it count % length-_ 0 target mylist[-1] + 1 target-mylist [count length) low = O high#len (mylist) -1 low high: mid (1ow + high), // 2 my1ist [mid] target: i mylist(mid]target: time2 time.clock) ttime2 timel number of trials xperiment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!