Unformatted text preview: v matches the text character just read. The start node means “Read the next character.” 2. Let X = x 1 x 2 ··· x n and Y = y 1 y 2 ··· y n be two character strings. We say that X is a cyclic shift of Y if there is r such that X = y r +1 ··· y n y 1 ··· y r . Give an O ( n ) algorithm to determine whether X is a cyclic shift of Y . 3. Let [ x 1 ,x 2 , ··· ,x n ] be a sequence of numbers. A subsequence of length k is a sequence [ x i 1 ,x i 2 , ··· x i k ], where 1 ≤ i 1 < i 2 < ··· < i k ≤ n . The subsequence is called increasing if x i 1 < x i 2 < ··· < x i k . (For example, both [1 , 2 , 4 , 7] and [1 , 3 , 9] are increasing subsequences of [1 , 3 , 2 , 4 , 9 , 7 , 3].) Explain how to use dynamic programming to ﬁnd the longest increasing subsequence of a given sequence [ x 1 ,x 2 , ··· ,x n ] in O ( n 2 ) time. 1...
View
Full
Document
This note was uploaded on 02/04/2010 for the course COMPUTER S cs300 taught by Professor Unkown during the Spring '08 term at Korea Advanced Institute of Science and Technology.
 Spring '08
 Unkown
 Algorithms

Click to edit the document details