Docsity

CS 470 Quiz 20: Longest Common Subsequence and Edit Distance, Quizzes of Algorithms and Programming

Toggle sidebar
bg1
CS 470 Quiz 20 Name ________________________
a. You are given strings S = cbda and T = bcad. Trace the dynamic programming
algorithm to compute the length of the longest common subsequence for strings S and
T. Also reconstruct all possible optimum solutions; that is, find all common
subsequences of strings S and T that have this greatest length.
j=0 j=1 j=2 j=3 j=4
i=0 0 0 0 0 0
i=1 0 0 1 1 1
i=2 0 1 1 1 1
i=3 0 1 1 1 2
i=4 0 1 1 2 2
The 4 optimum solutions are: (i) cd, (ii) bd, (iii) ca, (iv) ba.
b. You are given strings S = cbda and T = bcad. Trace the dynamic programming
algorithm to compute the edit distance between strings S and T (that is, the smallest
number of insert, delete, and replace operations that can transform S into T). Also
reconstruct all possible optimum solutions; that is, find all shortest sequences of edit
operations that transform S into T.
j=0 j=1 j=2 j=3 j=4
i=0 0 1 2 3 4
i=1 1 1 1 2 3
i=2 2 1 2 2 3
i=3 3 2 2 3 2
i=4 4 3 3 2 3
The 2 optimum solutions are:
i. Insert b, [Keep c], Replace b by a, [Keep d], Delete a.
ii. Delete c, [Keep b], Replace d by c, [Keep a], Insert d.

Partial preview of the text

Download CS 470 Quiz 20: Longest Common Subsequence and Edit Distance and more Quizzes Algorithms and Programming in PDF only on Docsity!

CS 470 Quiz 20 Name ________________________ a. You are given strings S = cbda and T = bcad. Trace the dynamic programming algorithm to compute the length of the longest common subsequence for strings S and T. Also reconstruct all possible optimum solutions; that is, find all common subsequences of strings S and T that have this greatest length. j=0 j=1 j=2 j=3 j= i=0 0 0 0 0 0 i=1 0 0 1 1 1 i=2 0 1 1 1 1 i=3 0 1 1 1 2 i=4 0 1 1 2 2 The 4 optimum solutions are: (i) cd , (ii) bd , (iii) ca , (iv) ba. b. You are given strings S = cbda and T = bcad. Trace the dynamic programming algorithm to compute the edit distance between strings S and T (that is, the smallest number of insert, delete, and replace operations that can transform S into T). Also reconstruct all possible optimum solutions; that is, find all shortest sequences of edit operations that transform S into T. j=0 j=1 j=2 j=3 j= i=0 0 1 2 3 4 i=1 1 1 1 2 3 i=2 2 1 2 2 3 i=3 3 2 2 3 2 i=4 4 3 3 2 3 The 2 optimum solutions are: i. Insert b , [Keep c ], Replace b by a , [Keep d ], Delete a. ii. Delete c , [Keep b ], Replace d by c , [Keep a ], Insert d.