Here is the formula:

m(a,b) = if a==b then 0 else 1
The line with "min" is the recursive formula itself, the rest are the non-recursive cases that the recursion leads to.
Your string uses "caching" the results in an array. Try to look at it as:
d(i, j) = Minimum (d(i-1, j)+1, d(i, j-1)+1, d(i-1, j-1) + cost);
costis m(a,b), and it is zero, if a==bone in the other case
source
share