Consider the following list of 20 elements sorted in ascending order:
lis = [1,3,4,6,7,9,10,11,12,14,16,17,20,26,29,30,31,32,34,40]
Suppose we searching for the value 45. How many elements will be checked if we use linear search? How many elements will be checked if we use binary search?
Assume we are using the versions of both taught in zybook sections 13.5 and 13.6, with no changes to improve performance.
a.
Linear Search: 20
Binary Search: 1
b.
Linear Search: 0
Binary Search: 0
No values checked, as 45 is not in the list.
c.
Linear Search: 5
Binary Search: 5
d.
Linear Search: 19
Binary Search: 4
e.
Linear Search: 10
Binary Search: 5
f.
Linear Search: 20
Binary Search: 5
g.
Linear Search: 20
Binary Search: 20