Question: VI. (20 points) Suppose that you are given an array A[1..n) of distinct numbers. You are told that the sequence A(1), A[2),..., A[n] is uni-

 VI. (20 points) Suppose that you are given an array A[1..n)

VI. (20 points) Suppose that you are given an array A[1..n) of distinct numbers. You are told that the sequence A(1), A[2),..., A[n] is uni- modal: For some index p between 1 and n, the values in A increase up to position p in A, and then decrease the remainder of the way until position n. However, you do NOT know what the index p is. For example, the following array A = [10, 15, 30, 25, 13,9,6] is unimodal: The numbers increase up to position 3 (assuming the starting position is 1), and then decrease all the way till the end. You'd like to find the peak entry in A (that is, the index p) by checking/comparing O(lgn) entries of A. Give an algorithm that, given a unimodal array A[1..n), returns the index p of the peak entry by comparing O(lg n) entries of A

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!