Reference no: EM132206608
WRITE-UP ONLY, NO NEED FOR A CODE!!
Suppose you are given an array A with n entries, with each entry holding a distinct number.
You are told that the sequence of values A[1], A[2], . . . , A[n] is unimodal, that is - For some index p between 1 and n, the values in the array entries increase up to position p in A and then decrease the remainder of the way until position n.
(So if you were to draw a plot with the array position j on the x-axis and the value of the entry A[j] on the y-axis, the plotted points would rise until x-value p, where they'd achieve their maximum, and then fall from there on.)
You'd like to find the "peak entry" p without having to read the entire array-in fact, by reading as few entries of A as possible.
Show how to find the entry p by reading at most O(log n) entries of A.
Describe this in your README. Prove that your algorithm works in O(logn). No need to provide code.