in Databases retagged by
689 views
3 votes
3 votes
Assume that a data file has an index consisting of $\text{N}$ items, where $\text{N}$ is large. If a binary search of the index is used to find an item, then, of the following, which best approximates the mean number of comparisons required to locate a specific index entry?
  1. $\text{(N}+1) / 2$
  2. $\text{N(N}-1) / 2$
  3. $\left(\log _2 \text{N}\right)-1$
  4. $\text{N} \log _2 \text{N}$
in Databases retagged by
689 views

6 Comments

worst case time complexity of binary search algorithm is log N but why do we’ve -1 at the end?
0
0
bro , bkz it is asking mean no. of comaprisons not time complexity
0
0
Have a doubt over this question, applying binary search is okay but does this means the index consisting of N items is sorted ?  it is not mentioned in the question anywhere and Is it a prerequisit to be known that index of N items is already sorted as we are applying binary search which works only on sorted values ??

(If its unsorted and binary search is applied we might not get the element (bcos of approach) but number of comparision remains same as mentioned logn -1 )

Pls let me know if there is any correction in my comment !!
0
0

$ \large{\colorbox{yellow}{Detailed video solution of this question with direct time stamp}}$
All India Mock Test 3 - Solutions Part 2

1
1
Thank u for the clarification Sir !!
0
0
yeah bro got it now ,another silly mistake of not considering whether it’s asking about time complexity or number of comparisons
0
0

Please log in or register to answer this question.

Answer:

Related questions