Homework 4
Document last modified:
|
æ c if n = 1 T(n) = í è 3T(ën/2û) + n if n > 1 |
This is not the usual binary search, here the array is unordered. We are searching to determine if a given key is a member of the array A.
| boolean member(int A[], int key, int l, int r) { if( l > r ) return false; int mid = (l+r)/2; if ( A[mid] == key ) return true; return member( A, key, l, mid-1) || member( A, key, mid+1, r); } |
Give the recurrence equation for member using floor and ceiling.
Give the recurrence equation.
Use a recursion tree to determine a good asymptotic upper bound, O, on the recurrence.
Use substitution to verify your answer.
Hint: Use change of
variables in h, see page 66 of text.
Turn in