Menu

[Solved]-Question 2 25 Points Longest Common Subsequence Consider Procedure Determine Length Longes Q37247371

Question 2 (2.5 points) Longest common subsequence. Consider the procedure to determine the length of the longest common subs

Question 2 (2.5 points) Longest common subsequence. Consider the procedure to determine the length of the longest common subsequence, LCS- LENGTHX, Y). It solves the LCS problem in a bottom-up manner, by filling out a 2-D tabular LCS-LENGTH(X, ) 2. n-Ylength 3. let c[O.m, 0.n] be a new array 4. for i 0 to m forj- 0 to n 6. 7. else if X i] 9 10 else 12. return cm, n For example, X-(B, C, B, D, C) and Y = (B,C, A,B,C), because the last two elements are the same (C), we have LCS(X, Y) = LCS(X1:4,h4) + 1. If we represent LCS(X,Y) with the table entry c[5,5], then c[5,5] c[4,4]1. Here, c[4,4] is the solution to the subproblem: LCS of (B, C, B, D) and (B, C, A, B) The following table is partially filled. 0 3 4 5 У, В С А В С 4 D 01 a) Explain why c[1,1] to c[1,5] and c[2,1] to c[5,1] are all 1s? b) Compute c[2,2], and which cell do you refer to when computing it’? c) Compute c[2,3] and c[3,2], which cell do you refer to directly this time? d) Fill up the rest of the cells. Assume that you take c[i.j – 1] when there is a draw in line 11. (L.e., take the first element) Show transcribed image text Question 2 (2.5 points) Longest common subsequence. Consider the procedure to determine the length of the longest common subsequence, LCS- LENGTHX, Y). It solves the LCS problem in a bottom-up manner, by filling out a 2-D tabular LCS-LENGTH(X, ) 2. n-Ylength 3. let c[O.m, 0.n] be a new array 4. for i 0 to m forj- 0 to n 6. 7. else if X i] 9 10 else 12. return cm, n For example, X-(B, C, B, D, C) and Y = (B,C, A,B,C), because the last two elements are the same (C), we have LCS(X, Y) = LCS(X1:4,h4) + 1. If we represent LCS(X,Y) with the table entry c[5,5], then c[5,5] c[4,4]1. Here, c[4,4] is the solution to the subproblem: LCS of (B, C, B, D) and (B, C, A, B) The following table is partially filled. 0 3 4 5 У, В С А В С 4 D 01 a) Explain why c[1,1] to c[1,5] and c[2,1] to c[5,1] are all 1s? b) Compute c[2,2], and which cell do you refer to when computing it’? c) Compute c[2,3] and c[3,2], which cell do you refer to directly this time? d) Fill up the rest of the cells. Assume that you take c[i.j – 1] when there is a draw in line 11. (L.e., take the first element)

Expert Answer


Answer to Question 2 (2.5 points) Longest common subsequence. Consider the procedure to determine the length of the longest common… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *