You are given an array A of n elements whose entries are distinct integers. Assume that n ≥ 2. An index j is called a local minimum of A if one of the following conditions holds:
• j = 1 and A[1] < A[2].
• j = n and A[n] < A[n − 1].
• 1 < j < n, A[j] < A[j − 1], and A[j] < A[j + 1].
Find a local minimum of A in O(log n) time. Go through each step, be very systematic.
a. Convince an understanding of what a local minimum is by giving an example of an array A[1 . . . 10] of distinct integers such that none of the indices in {1, 2, 3, 4, 5} is a local minimum, but A has three different local minima.
b. From now on, consider a general n. Prove that A is guaranteed to have a local minimum. Keep it brief.
c. Provide pseudocode for a recursive divide-and-conquer algorithm that solves the problem of finding a local minimum of A. Prove the correctness of your algorithm by appropriately referring to or extending your previous proof.
d. Prove that your algorithm’s worst-case runtime T(n) satisfies T(n) ≤ T(n/2) + O(1). Solve the recurrence, in an asymptotic sense, to complete the algorithm analysis.