Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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) 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started