1.0022    Given sorted lists of 173, 3200, and 5600  names, what is the maximum number of comparisons will it take to find an name using a binary search? The average number of comparisons?

 

Using a binary search, the maximum number of searches is: (the ceiling of)  log2 n. Therefore:

 

For 173 elements:   (ceiling of) log2 173 =  (ceiling of) 7.43 = 8

For 3200 elements: (ceiling of) log2 3200 =  (ceiling of) 11.64 = 12

For 5600 elements: (ceiling of) log2 5600 =  (ceiling of) 12.45 = 13

 

The Average number of searches is (log2 n) – 1. Therefore:

 

For 173 elements:   (log2 173) – 1 = 7.43 – 1 = 6.43

For 3200 elements: (log2 3200) – 1 = 11.64 – 1 = 10.43

For 5600 elements: (log2 5600) – 1 = 12.45 – 1 = 11.45