Question: Longest common subsequence of three strings. We are given three strings a = (a1, a2, . . . , a l ), b = (b1,

Longest common subsequence of three strings.

We are given three strings a = (a1, a2, . . . , al), b = (b1, b2. . . . , bm), and c = (c1, c2, . . . , cn). Find the maximum length of a common subsequence of a, b, and c (i.e., the number of characters in a longest string that is the substring of a, b and c).

We define subproblems as follows. For i = 0, . . . , l`, j = 0, . . . , m, and k = 0, . . . , n, let OPT(i, j, k) denote the maximum length of a subsequence of the three strings (a1, . . . , ai), (b1, . . . , bj ), and c(1, . . . , k). Then the original problem is to find OPT(l, m, n). Note that if any of the words has zero letters, then any common subsequence has 0 length. Consequently, OPT(0, j, k) = 0, OPT(i, 0, k) = 0, and OPT(i, j, 0) = 0 for all i, j, k.

(a) Find a recurrence relation for OPT(i, j, k), i, j, k 1; justify your answer.

(b) Provide pseudocode for a DP algorithm that returns OPT(l, m, n).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!