Solution Library
Binary Search AlgorithmMultiple Choice Question
Question
Consider the following Binary Search Algorithm
upper = length  1;
lower = 1;
while (upper >= lower)
{ mid_pt = (upper + lower) / 2;
if (data[mid_pt] < target) ; comparison A
{ lower = mid_pt + 1; }
else if (data[mid_pt] == target) ; comparison B
{ return mid_pt; }
else { upper = mid_pt – 1;}
}
//target not found
Give the values for lower, upper and midpt for each iteration of the while loop and state how many times will the two comparisons A and B be executed using this algorithm to find the value 77 in the following array? You may not need to complete all the rows.
[0] 
[1] 
[2] 
[3] 
[4] 
[5] 
[6] 
[7] 
[8] 
[9] 
[10] 
[11] 
[12] 
14 
27 
29 
38 
42 
55 
57 
61 
64 
69 
77 
79 
84 



Lower 
Upper 
Midpt 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Comparison A executed  times & Comparison B executed  times.
Download Full Solution
Comments
this is a very good website
I have 50 questions for the same test your page is showing only 28
hi can you please help or guide me to answer my assignments. thanks
hi can anyone help or guide me to my assignments. thanks
This solution is perfect ...thanks
Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes
Perfect bank of solution.
great !
thanks for the quick response. the solution looks good. :)
thnx for the answer. it was perfect. just the way i wanted it.
works fine.