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?
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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.