This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Problem 54. 10pts 1. 10pts Design an O ( n 2 ) algorithm to ﬁnd the length of the longest monotonically increasing subsequence of a sequence of n numbers. 2. Extra Credit Explain how to modify your algorithm to run in O ( n log n ) time. Problem 55. 15pts Design an O ( n 2 ) algorithm to ﬁnd the length of a longest subsequence that ﬁrst monotonically increases and then monotonically decreases. For example, if the input sequence is 1 , 7 , 4 , 9 , 5 , 3 , 8 , 7 , 2, then 1 , 4 , 3 , 2 is such a sequence, as well as 7 , 3 , 2 and 1 , 7 , 9. (Note that the second example misses ”increasing” part, and the third is missing the ”decreasing” part.) For this example, the answer is 6: (1, 7, 9, 5, 3, 2) or (1, 7, 9, 8, 7, 2). Problem 56. 25pts Solve problem CLRS 15.6, page 408 (Second edition: 15.4, page 367) 1...
View
Full
Document
This note was uploaded on 02/01/2011 for the course MATH 171 taught by Professor R during the Spring '09 term at Stanford.
 Spring '09
 R
 Dynamic Programming

Click to edit the document details