2,938 views
2 votes
2 votes
If the binary search algorithm determines that the scanned argument is in upper half of the array,which of the following statement will set the appropriate variable to the appropriate value.

A) startsub= middlesub-1;

B) startsub=middlesub+1;

C)stopsub=middlesub-1;

D)stopsub=middlesub+1;

2 Answers

Best answer
4 votes
4 votes
Option B is Ans

Cz as we know the Searching element is in Upper half then We will Increase the middlesub index  by 1. So that our search space is reduced by half.

So stopsub as it is and startsub=middlesub+1

So option B is correct Ans.
selected by

Related questions

4 votes
4 votes
4 answers
1
Parshu gate asked Nov 27, 2017
6,662 views
How many different binary search trees can be constructed using six distinct keys? 256 128 132 264
10 votes
10 votes
3 answers
2
Chandramani Adil asked Aug 16, 2017
1,466 views
Suppose the first step in binary search algorithm is changed to M = (9L+R)/10, we know that the complexity of binary search is log(n). What will be the complexity of modi...
0 votes
0 votes
2 answers
3
dhruba asked Jun 5, 2023
1,091 views
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). ...
1 votes
1 votes
4 answers
4
Abhishek Kumar 38 asked Dec 15, 2018
2,056 views
There are two sorted list each of length n. An element to be searched in the both the lists. The lists are mutually exclusive. The maximum number of comparisons required ...