Question: The following algorithm performs a search of an array for key: int search(int A[], int key, int low, int high) { if (low > high)

 The following algorithm performs a search of an array for key:

The following algorithm performs a search of an array for key: int search(int A[], int key, int low, int high) { if (low > high) return -1; int mid (low + high)/2; if (key A[mid]) return mid; int resulti search(A, key, mid + 1, high); int result2 search(A, key, low, mid - 1); if (resulti != -1) return resulti; return result2 } What is a reasonable definition of the corresponding recurrence relation T(n)? O T(n) = 2T/2) + c orcin = 1 Tn) = 2T(n) + C or cit n = 1 OT(n) = T(n/2) + c orcin = 1 O T(n) = T(2n) + c orcin - 1

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!