Question: ( 2 0 points ) Design an O ( l o g n ) - time algorithm for the problem described below. ( i )

(20 points) Design an O(logn)-time algorithm for the problem described below. (i) Provide your algorithm in pseudocode. (ii) Explain your algorithm in plain English discussing why it is correct, and (iii) justify why the running time is O(logn).
Find-Max (A[1,dots,n]) :
Input: An array A[1,dots,n] of numbers with the following property. There exists m such that 1mn and A[1,dots,m] is a strictly increasing sequence and A[m,dots,n] is a strictly decreasing sequence of numbers. That is, there is some m for which A[1]A[m+1]>cdots>A[n](For example, A could be the sequence (1,5,8,12,11,4,2), where m would be 4.)
Output: i such that A[i]=max{A[1],dots,A[n]}(In the given example, the correct output would be 4, since A[4]=12 is the largest number in the input array A).
( 2 0 points ) Design an O ( l o g n ) - time

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 Programming Questions!