Let denote C(m, n) for the special case when thecost I(x) of every insertion is
ID: 3609009 • Letter: L
Question
Let denote C(m, n) for the special case when thecost I(x) of every insertion is 1,the cost D(x) of every deletion is 1, and the cost S(x, y) of everysubstitution is 3
if x y and is 0 if x = y. Let be thelength of a longest subsequence
that is common to both A and B. Write down an expressionfor as a function of m, n,
and . ----------------Background andNotation------------------------------------------- Recall that this is the problem of finding a minimumcostsequence of operations on a given
string A = a1a2 . . . am thattransforms it into another given string B =b1b2 . . . bn.
The symbols in A and B are from an alphabet of constant size
(e.g., for lowercase English, the alphabet size is 26). The allowedtypes of operations are
(i) inserting a symbol x into A, whose cost is denoted by I(x);
(ii) deleting a symbol x from A, whose cost is denoted byD(x);
(iii) substituting in A a symbol y for a symbol x, whose cost isdenoted by S(x, y).
The I, D and S cost tables are given as part of the input, alongwith the two input strings A and B. The O(mn) time algorithmrelies on computing the entries of an (m+1) × (n + 1) table Cin which C(i, j), for 1<= i <=m and 1<=j<=n, is theminimum cost of transforming a1 . . . ai intob1 . . . bj .
C(0, j) is the minimum cost of transforming the empty string intob1 . . . bj , and C(i, 0) is the minimum
cost of transforming a1 . . . ai into theempty string. The crucial observations that made the O(mn) time
algorithm possible were the following equations. Equations forC
1. C(0, j) = I(b1) + I(b2) + ·· · + I(bj)
2. C(i, 0) = D(a1) + D(a2) + ·· · + D(ai)
3. C(i, j) = min{C(i, j 1) + I(bj),C(i 1, j) + D(ai),C(i 1, j 1) +S(ai, bj)}
computing C(m, n) can be done in O(mn) time and O(m+n) space. Wealso explained how,
if we use O(mn) space, we can compute in O(mn) time not only C(m,n) but also
the optimal sequence of operations that achieves that C(m, n)cost.
The purpose of this homework is to explore an O(m+n) spacealgorithm for finding the
optimal sequence of operations in O(mn) time Let denote C(m, n) for the special case when thecost I(x) of every insertion is 1,
the cost D(x) of every deletion is 1, and the cost S(x, y) of everysubstitution is 3
if x y and is 0 if x = y. Let be thelength of a longest subsequence
that is common to both A and B. Write down an expressionfor as a function of m, n,
and . ----------------Background andNotation------------------------------------------- Recall that this is the problem of finding a minimumcostsequence of operations on a given
string A = a1a2 . . . am thattransforms it into another given string B =b1b2 . . . bn.
The symbols in A and B are from an alphabet of constant size
(e.g., for lowercase English, the alphabet size is 26). The allowedtypes of operations are
(i) inserting a symbol x into A, whose cost is denoted by I(x);
(ii) deleting a symbol x from A, whose cost is denoted byD(x);
(iii) substituting in A a symbol y for a symbol x, whose cost isdenoted by S(x, y).
The I, D and S cost tables are given as part of the input, alongwith the two input strings A and B. The O(mn) time algorithmrelies on computing the entries of an (m+1) × (n + 1) table Cin which C(i, j), for 1<= i <=m and 1<=j<=n, is theminimum cost of transforming a1 . . . ai intob1 . . . bj .
C(0, j) is the minimum cost of transforming the empty string intob1 . . . bj , and C(i, 0) is the minimum
cost of transforming a1 . . . ai into theempty string. The crucial observations that made the O(mn) time
algorithm possible were the following equations. Equations forC
1. C(0, j) = I(b1) + I(b2) + ·· · + I(bj)
2. C(i, 0) = D(a1) + D(a2) + ·· · + D(ai)
3. C(i, j) = min{C(i, j 1) + I(bj),C(i 1, j) + D(ai),C(i 1, j 1) +S(ai, bj)}
computing C(m, n) can be done in O(mn) time and O(m+n) space. Wealso explained how,
if we use O(mn) space, we can compute in O(mn) time not only C(m,n) but also
the optimal sequence of operations that achieves that C(m, n)cost.
The purpose of this homework is to explore an O(m+n) spacealgorithm for finding the
optimal sequence of operations in O(mn) time ----------------Background andNotation------------------------------------------- Recall that this is the problem of finding a minimumcostsequence of operations on a given
string A = a1a2 . . . am thattransforms it into another given string B =b1b2 . . . bn.
The symbols in A and B are from an alphabet of constant size
(e.g., for lowercase English, the alphabet size is 26). The allowedtypes of operations are
(i) inserting a symbol x into A, whose cost is denoted by I(x);
(ii) deleting a symbol x from A, whose cost is denoted byD(x);
(iii) substituting in A a symbol y for a symbol x, whose cost isdenoted by S(x, y).
The I, D and S cost tables are given as part of the input, alongwith the two input strings A and B. The O(mn) time algorithmrelies on computing the entries of an (m+1) × (n + 1) table Cin which C(i, j), for 1<= i <=m and 1<=j<=n, is theminimum cost of transforming a1 . . . ai intob1 . . . bj .
C(0, j) is the minimum cost of transforming the empty string intob1 . . . bj , and C(i, 0) is the minimum
cost of transforming a1 . . . ai into theempty string. The crucial observations that made the O(mn) time
algorithm possible were the following equations. Equations forC
1. C(0, j) = I(b1) + I(b2) + ·· · + I(bj)
2. C(i, 0) = D(a1) + D(a2) + ·· · + D(ai)
3. C(i, j) = min{C(i, j 1) + I(bj),C(i 1, j) + D(ai),C(i 1, j 1) +S(ai, bj)}
computing C(m, n) can be done in O(mn) time and O(m+n) space. Wealso explained how,
if we use O(mn) space, we can compute in O(mn) time not only C(m,n) but also
the optimal sequence of operations that achieves that C(m, n)cost.
The purpose of this homework is to explore an O(m+n) spacealgorithm for finding the
optimal sequence of operations in O(mn) time
Explanation / Answer
Dear User, An expression for as a function of m,n and is = (m + n - )/2 I hope this will helps toyouRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.