Menu

(Solved) : Given Two Strings X X1 X2 Xn Y Y1 Y2 Ym Give Dynamic Programming Algorithm Find Length K Q34260146 . . .

Given two strings X = x1,x2,…,xn and Y = y1,y2,…,ym give adynamic programming algorithm to find the length k of the longeststring Z = z1, . . . , zk where Z appears as a substring of X andas a subsequence of Y . Recall, a substring means consecutiveelements.

For example, for the following input:
X = a,b,d,b,a,b,f,g,d

Y = b,e,t,f,d,b,f,a,f,r

then the answer is 4 (since, b, d, b, a is a substring of X andit is also a subsequence of Y). You do not need to output theactual substring, just its length.

(Faster (and correct) in asymptotic O(·) notation is worth morecredit.)

(a) Define the entries of your table in words. E.g., T (i) or T(i, j) is ….

(b) State recurrence for entries of table in terms of smallersubproblems.

(c) Write pseudocode for your algorithm to solve thisproblem.

Expert Answer


Answer to Given Two Strings X X1 X2 Xn Y Y1 Y2 Ym Give Dynamic Programming Algorithm Find Length K Q34260146 . . .

OR