Question

Question 1 (Longest Common Subsequence) In the longest common sub- sequence algorithm we discussed in class, we formulated thNeed help with all 3 parts. Thanks

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

Solution:

The longest common subsequence (LCS) problem can be solved using a dynamic programming solution with the help of a recurrence relation. The longest common subsequence means the length of the maximum subsequence common between any given two strings X and Y.

(a)

% 74x830<щ 330K и ирит (т-ши ) 527 ) you (ш») — = Их 33 04щ 33 о?и ити” (т-lut-u) 527 11 = (кu) 521 o=щ 10 0= 4 томат

=>Here LCS(n,m) represents the recursion function of the longest common subsequence between two strings X and Y of lengths n and m respectively.

Based on the conditions written at the right of the longest common subsequence functions we follow the result.Here max represents the maximum length out of LCS(n-1,m) and LCS(n,m-1).

=> Here xn and ym represent the string length at any given point.

(b)

Pseudo code e- when two strings of lengths in and n are given int Leslint n, int m) IF (na roll M==0) - return o; else if I n

Given is the pseudo-code of the algorithm. We follow two approaches to calculate the longest common subsequence value between two strings X and Y.

=>Two approaches are a bottom-up approach and a top-down approach. The result obtained in both approaches will be the same.

=>In the bottom-up approach we fill the table from bottom to the top manner and in a top-down approach, we fill the table from top to bottom manner.

(c)

Given X = {A, B, C, B, D, A, B} and Y= {B, D, C, A, B, A}

Date: - (५) В С В Д А В Bा ५५ 32 0333332L c 33-32 2 2 । ___32222-2 22.9 । । 16-1 000000

I have created a table using the bottom-up approach and the recurrence relation of the dynamic programming solutions.

=> The length of the longest common subsequence which is at the corner of the left-most upper corner.

=> I have drawn an arrow from down to upward direction which indicates matching characters.

=> The longest common subsequence is B, C, B, A which is common in both.

I have explained each and every step through images as well as statements.

Add a comment
Know the answer?
Add Answer to:
Need help with all 3 parts. Thanks Question 1 (Longest Common Subsequence) In the longest common...
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
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