Question: The psuedo - code below gives a slightly different version of binary search: RecBinarySearch 2 ( low , high,A , x ) If ( ?

The psuedo-code below gives a slightly different version of binary search:
RecBinarySearch2(low,high,A,x)
If (??), Return(1)
mid:=low+high2
If (x=amid), then Return( mid )
If (xamid), then low:=mid+1
Return( RecBinarySearch2(low,high,A,x))
(a)
What is the right condition for the base case?
(b)
Consider running RecBinarySearch2 on input list:
(2,5,8,11,15,18,23,29,31,35)
In searching for a target item x that is in the list, the running time of the algorithm may differ depending on which item from the list is the target item. Give a target item x, selected from the list, that results in the best running time. Give a target item, selected from the list, that results in the worst running time.

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 Programming Questions!