retagged by
1,281 views
0 votes
0 votes
Binary search is performed on a sorted array of n elements. The search key is not in the array and falls between the elements at positions m and m+1 (where 1 ≤ m < n). How many comparisons are needed in the worst case scenario to determine that the key is not in the array?

a. ceil(log(n))

b. floor(log(n))

c. ceil(log(m))

d. floor(log(m))
retagged by

2 Answers

1 votes
1 votes
The search key is not in the array and falls between the elements at positions m and m+1 (where 1 ≤ m < n).
This statement describes a scenario where you are performing a binary search on a sorted array, and the search key is not present but its value lies between two consecutive elements in the array.
0 votes
0 votes

the answer is a ceil(o(logn))  because it’s just asking the worst case complexity of binary search and try to make students confuse , also ans is always in a ceil value not float remember

 

Related questions

1.5k
views
1 answers
2 votes
yes asked Oct 6, 2015
1,460 views
for example array contain a[1 2 3 3 3 3 3 4 5] then retun(1)
846
views
1 answers
1 votes
20.9k
views
2 answers
8 votes
radha gogia asked Jul 19, 2015
20,896 views
(A) Insertion Sort with time complexity O(kn)(B) Heap Sort with time complexity O(nLogk)(C) Quick Sort with time complexity O(kLogk)(D) Merge Sort with time complexity O(kLogk) what is the approach of doing this question ?