Question

2. (40 pts) Let A, B, and C be three strings each n characters long. We want to compute the longest subsequence that is commo

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) This will correct solution because atleast LCS of 3 strings will be obtained by applying for any 2 also, and

    then we can apply LCS for third and this string, to get for LCS of all three. This Proves that whatever

    Order of applying LCS to any of three strings first and LCS to the third next will give the correct soluttion

b)

The idea is to take a 3D array to store the 
length of common subsequence in all 3 given 
sequences i. e., L[m + 1][n + 1][o + 1]

1- If any of the string is empty then there
   is no common subsequence at all then
           L[i][j][k] = 0

2- If the characters of all sequences match
   (or X[i] == Y[j] ==Z[k]) then
        L[i][j][k] = 1 + L[i-1][j-1][k-1]

3- If the characters of both sequences do 
   not match (or X[i] != Y[j] || X[i] != Z[k] 
   || Y[j] !=Z[k]) then
        L[i][j][k] = max(L[i-1][j][k], 
                         L[i][j-1][k], 
                         L[i][j][k-1])
Add a comment
Know the answer?
Add Answer to:
2. (40 pts) Let A, B, and C be three strings each n characters long. We want to compute the longest subsequence that is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. (40 pts) Let A, B, and C be three strings each n characters long. We want to compute the longest subsequence th...

    2. (40 pts) Let A, B, and C be three strings each n characters long. We want to compute the longest subsequence that is common to all three strings. (a) Let us first consider the following greedy algorithm for this problem. Find the longest common subsequence between any pair of strings, namely, LCS(A, B). LCS(B,C), LCS(A, C). Then, find the longest common subsequence between this LCS and the 3rd string. That is, supposing that the longest common pair wise subsequence...

  • need the answer to b not a. thanks! 2. (40 pts) Let A, B, and C be three strings each n characters long. We want t...

    need the answer to b not a. thanks! 2. (40 pts) Let A, B, and C be three strings each n characters long. We want to compute the longest subsequence that is common to all three strings. (a) Let us first consider the following greedy algorithm for this problem. Find the longest common subsequence between any pair of strings, namely, LCS(A, B). LCS(B,C), LCS(A, C). Then, find the longest common subsequence between this LCS and the 3rd string. That is,...

  • Longest common subsequence (LCS) algorithms give a way to decide how similar two given strings are....

    Longest common subsequence (LCS) algorithms give a way to decide how similar two given strings are. However, sometimes, we have to filter away some common subsequences that are in some pattern. Here is a problem for you to solve. Given two strings alpha and beta, let gamma to be the longest word satisfying all of the following conditions: gamma is a subsequence of alpha. gamma is a subsequence of beta. gamma does not contain abb. Design an algorithm that finds...

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

    Question 2 (2.5 points) Longest common subsequence Consider the procedure to determine the length of the longest common subsequence, LCS- LENGTH(X, Y). It solves the LCS problem in a bottom-up manner, by filling out a 2-D tabular LCS-LENGTH(X, Y) m = X.length 2. n-Y.length 3. let cO.m, 0n] be a new array 4, for i = 0 to m for/ = 0 to n else if ATY ci,ci ,j-1 +1 10 else 12. return clm, n] For example, X (B,...

  • C. 7. True/False Questions. (2 points each) a. Applying Horner's Rule, an n-degree polynomial can be...

    C. 7. True/False Questions. (2 points each) a. Applying Horner's Rule, an n-degree polynomial can be evaluated at a given point using only n multiplications and n additions. b. Quick Sort and Merge Sort are comparison-based sorting algorithms. Heap Sort and Distribution Counting Sort are not comparison-based sorting algorithms. An AVL tree applies four types of rotations: RIGHT, LEFT, RIGHT-LEFT, and LEFT-RIGHT. d. When an AVL tree's left sub-tree is left-heavy, a LEFT rotation is needed. e. When an AVL...

  • We are given four items, namely A, B, C, and D. Their corresponding unit profits are...

    We are given four items, namely A, B, C, and D. Their corresponding unit profits are pA, pB, pC, and pD. The following shows five transactions with these items. Each row corresponds to a transaction where a non-negative integer shown in the row corresponds to the total number of occurrences of the correspondence item present in the transaction. T A B C D t1 0 0 3 2 t2 3 4 0 0 t3 0 0 1 3 t4 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT