ISRO | ISRO CS 2014 | Question 28
Suppose there are 11 items in sorted order in an array. How many searches are required on the average, if binary search is employed and all searches are successful in finding the item?
(A) 3.00
(B) 3.46
(C) 2.81
(D) 3.33
Answer: (A)
Explanation: For 11 items, Binary search required total number of comparisons for each item as following:
Therefore, total number of caparisons required
= 1*1 + 2*2 + 4*3 + 4*4 = 33
Average comparisons required for 11 items = 33/11 = 3
So, option (A) is correct.
Quiz of this Question
Please Login to comment...