in Unknown Category edited by
510 views
1 vote
1 vote

The program written for binary search, calculates the midpoint of the span as $\text{mid : =(Low+High)/2}$. The program works well if the number of elements in the list is small (about $32,000$) but it behaves abnormally when the number of elements is large. This can be avoided by performing the calculation as:

  1. $\text{mid :=(High-Low)/2+Low}$
  2. $\text{mid :=(High-Low+1)/2}$
  3. $\text{mid :=(High-Low)/2}$
  4. $\text{mid :=(High+Low)/2}$
in Unknown Category edited by
by
510 views

2 Answers

1 vote
1 vote
Eliminate option D due to it's same as the defective one.

considering Low index $=10,$ high index $= 15$

option B gives, mid index $= 3$ which is not even in the sub array index.

option C gives, mid index $= 2$ which is not even in the sub array index.

Option A is correct.
edited by
0 votes
0 votes

Option B  and Option C do not match    mid  =  (Low +High)/2

Option D is same as the defective one  mention in the question  mid = (low +High)/2

so Eliminate option B , C  and  D

now , lets solve 

mid = ( High – Low ) / 2 + Low

mid  = (High – Low + 2Low ) /2

mid = ( High + Low ) / 2     →  which is equivalent to     mid = ( Low + High ) / 2  given in the question 

so after solving we got  option ( A) is correct answer .

 

Answer:

Related questions