Question: Assume that you are using binary search algorithm to find the position of element x=9 in the list L={1,2,3,4,5,6,7,8,9,10). What is the number of comparisons

 Assume that you are using binary search algorithm to find the
position of element x=9 in the list L={1,2,3,4,5,6,7,8,9,10). What is the number

Assume that you are using binary search algorithm to find the position of element x=9 in the list L={1,2,3,4,5,6,7,8,9,10). What is the number of comparisons done by the algorithm until it finds the position of x? (Include all comparisons in your count!) Binary search algorithm is given as: procedure binary search(x:integer, a1,22,..., an increasing integers) i:=1 (i is the left endpoint of interval} j:=n(j is right endpoint of interval} whileiaj m:= [(i+j)/2] if x > am then i:=m+ 1 else j:=m j:= n(j is right endpoint of interval) while i am then i:=m+1 elsej:=m if x = a; then location := i else location := 0 return location Select one: O a. 5 O b. 10 OC8 O d. 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!