Menu

[Solved]1 Dynamic Programming Lcs Follow Code Determine Lcs Longest Common Subsequence 0 1 0 1 1 0 Q37248281

1. Dynamic Programming for lcs

a)Follow the code below to determine an LCS(Longest commonsubsequence) of<1,0,0,1,0,1,0,1> and < 0,1,0,1,1,0,1,1,0>. Please show the 2-D table c and b as being used in the pseudocode LCS length. Note the 2-D table b is set so that b[i,j] pointsto the table entry corresponding to the optimal subproblem solutionchosen when computing c[i,j].

b)Give pseudocode to reconstruct an LCS from the completed c tableand the original sequences X =< x1, x2, …, xm >, and Y=< y1, y2, …, yn > in O(m + n) time, without using the btable

LCS-LENGTH(X, Y) 1 m= X.length 2 n- Y.length 3 let b[1..m, 1..n] and c[0..m,0..n] be new tables 4 for i= l to m cli,0] = 0 0tLCS-LENGTH(X, Y) 1 m= X.length 2 n- Y.length 3 let b[1..m, 1..n] and c[0..m,0..n] be new tables 4 for i= l to m cli,0] = 0 0ton 6 for 8 fori – 1 to m for i – 1 to n 10 с[i, j] = с[1-1, j-1] + 1 12 13 14 15 16 17 18 return c and b 95 elseif c[i – 1,j] 2 c[i,j -1] bli. Λ = “1″, Show transcribed image text LCS-LENGTH(X, Y) 1 m= X.length 2 n- Y.length 3 let b[1..m, 1..n] and c[0..m,0..n] be new tables 4 for i= l to m cli,0] = 0 0ton 6 for 8 fori – 1 to m for i – 1 to n 10 с[i, j] = с[1-1, j-1] + 1 12 13 14 15 16 17 18 return c and b 95 elseif c[i – 1,j] 2 c[i,j -1] bli. Λ = “1″,

Expert Answer


Answer to 1. Dynamic Programming for lcs a)Follow the code below to determine an LCS(Longest common subsequence) of and < 0,1,0,1,... . . .

OR


Leave a Reply

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