from search import *
#make sure the file search.py
#from the previous lecture
#is found at the same directory as this file
####################################################
## Time measurements of sequential vs. binary search
####################################################
import time
for n in [10**6, 2*10**6, 4*10**6]:
print("n=", n)
L = [(i,"blabla") for i in range(n)] #generates the ordered list of keys 0,1,2,...,n-1
#generates the list
# [(0,’blabla’),(1,’blabla’),..., (n-1,’blabla’)]
# note that keys are ordered
t0 = time.clock()
for i in range(100): #do 100 times, for more significant statistics
sequential_search(-1,L) #search a key that does not exist
t1 = time.clock()
print("sequential search:", t1-t0)
t0 = time.clock()
for i in range(100): #do 100 times, for more significant statistics
binary_search(-1,L) #search a key that does not exist
t1 = time.clock()
print("binary search:", t1-t0)