Question: Question 3 Consider the following recursive implementation of the Binary Search: boolean binarySearch ( int arr [ ] , int left, int right, int key
Question
Consider the following recursive implementation of the Binary Search:
boolean binarySearchint arr int left, int right, int key
if right left
return false ;
int mid left right left;
if arrmid key
return true;
else if arrmid key
return binarySearcharr left, mid key;
else
return binarySearcharr mid right, key;
Write the recurrence relation describing the time behavior of the routine above.
Use the recurrence relation to determine the growth function of the routine.
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
