63
правки
Изменения
Нет описания правки
<tex>D(i, j) = \left\{\begin{array}{lllc}
\min{(A, D(i - 2, j - 2) + transposeCost)}&&;\ i > 1,\ j > 1,\ S[i] = T[j - 1],\ S[i - 1] = T[j]\\A&&;\ \text{otherwise}\\
\end{array}\right.
</tex>
<tex>
A = \left\{\begin{array}{llcl}
0&&;&\ i = 0,\ j = 0\\i&&;&\ j = 0,\ i > 0\\j&&;&\ i = 0,\ j > 0\\D(i - 1, j - 1)&&;&\ S[i] = T[j]\\
\min{(}\\
\qquad\ begin{array}{llcl}&D(i, j - 1) + insertCost\\&D(i - 1, j) + deleteCost&&\qquad\ &D(i - 1, j- 1) + deleteCost&replaceCost\\\end{array}&;&\ j > 0,\ i > 0,\ S[i] \ne T[j]\\\qquad\ D(i - 1, j - 1) + replaceCost\\
)
\end{array}\right.
, где
<tex>A = \left\{\begin{array}{llcl}0&&;&\ i = 0,\ j = 0\\i&&;&\ j = 0,\ i > 0\\j&&;&\ i = 0,\ j > 0\\D(i - 1, j - 1)&&;&\ S[i] = T[j]\\
\min{(}\\
\qquad\ begin{array}{llcl}&D(i, j - 1) + insertCost\\&D(i - 1, j) + deleteCost&&\qquad\ &D(i - 1, j- 1) + deleteCost&replaceCost\\\end{array}&;&\ j > 0,\ i > 0,\ S[i] \ne T[j]\\\qquad\ D(i - 1, j - 1) + replaceCost\\
)
\end{array}\right.