Question: The psuedo - code below gives a slightly different version of binary search: RecBinarySearch 2 ( low , high,A , x ) If ( ?
The psuedocode below gives a slightly different version of binary search:
RecBinarySearchlowhigh,Ax
If Return
mid:lowhigh
If xamid then Return mid
If xamid then low:mid
Return RecBinarySearchlowhigh,Ax
a
What is the right condition for the base case?
b
Consider running RecBinarySearch on input list:
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
