Remember to:
T(n) = 2T(n/2 + 17) + nis O(n log n).
Note: In case you find the notation above ambiguous, T(n/2 + 17) = T((n/2) + 17).
OPTIONAL PART (20 extra credit points): In addition to using the recursion-tree method above, use the (partial) substitution method to prove that T(n) is O(n log n). Remember that the substitution method involves 2 steps:
- (5 points) Guess a good upper bound. Explain why your guess makes sense.
- (15 points) Use mathematical induction to refine your guess (i.e., select the appropriate constants and/or add terms to your guess) and to show that the solution works.
Input: - An array A of n positions, containing a sorted (in ascending order) sequence of numbers. That is A[1] ≤ A[2] ≤ ... ≤ A[n]. - A value v. Output: - An index i such that v = A[i], OR the message "v is not in A" if v doesn't appear in A.Consider the following divide-and-conquer solution to this problem. This solution is called binary search: Compare the midpoint of the array A with v and eliminate half of the array from further consideration, until either v is found in A, or no elements in A remain under consideration.