Learn Before
Concept

Explanation for Minimum Edit Distance Algorithm

To compute the minimum edit distance of two strings, we will need to compute bottom-up, combining solutions to subproblems.

First, we need to consider the basic cases : D[0,1]=1D[0, 1] = 1, which means to convert a null string to a string with one character. The edit distance is one insertion.

D[1,0]=1D[1, 0] = 1, which means to convert a string with one character to a null string. The edit distance is one deletion.

D[1,1]=0or2D[1,1] = 0 \quad or \quad 2 , which means to convert a string with one character to another string with one character. The edit distance is zero if two characters are the same, while the edit distance is two if two characters are different.

Then we compute larger cases based on previous values.

D[i,j]=min{ D[i1,j]+1D[i,j1]+1D[i1,j1]+{2;ifsource[i]target[j]0;ifsource[i]=target[j]D[i, j] = min \begin{cases}\ D[i - 1, j] +1 \\D[i, j - 1] +1 \\D[i- 1, j - 1] +\begin{cases} 2;\quad if source[i] \neq target[j]\\0; \quad if source[i] = target[ j]\end{cases} \end{cases}

0

1

Updated 2021-09-18

Tags

Data Science