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
 Spring '08
 Unkown
 Algorithms, Vibrating string, ASCII, subsequence, Longest common subsequence problem, KMP

Click to edit the document details