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

The trace of the dynamic programming algorithm to compute the length of the longest common subsequence and the edit distance between two strings, s = cbda and t = bcad. It also reveals the optimum solutions for each problem.

Typology: Quizzes

Pre 2010

Uploaded on 02/24/2010

koofers-user-qlx
koofers-user-qlx 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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.