Question: Question 3 : Longest Common Subsequence ( 1 0 points ) Given two strings, S 1 and S 2 , the task is to find

Question 3: Longest Common Subsequence (10 points)
Given two strings, S1 and S2, the task is to find the length of the Longest Common Subsequence (LCS), i.e. longest
subsequence present in both of the strings. For example, for S1=AGGTAB, S2=GXTXAYB
the output is 4, as the LCS is GTAB. For S1=BD, S2=ABCD, the output is 2 as the LCS is BD.
1) Please design an efficient algorithm to solve the LCS. Whats its time complexity?
2) Can you augment the algorithm to not only print out the length of the LCS, but also the LCS itself?

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 Programming Questions!