The Column for Letter "T"
Now that we've successfully filled in the columns for B
, E
, and S
, we can wrap up our matrix with the last column for the letter T
from the string best
.
Calculating the Costs for "T"
Starting with the first row, T
and t
are the same characters, so the edit cost is 0
. The calculations for this cell are:
- From Above: (4 + 1 = 5)
- From the Left: (3 + 1 = 4)
- From the Diagonal: (3 + 0 = 3)
The minimum of these is 3
, so we place it in the cell where T
intersects with t
.
The Final Matrix
Here's how our fully completed matrix looks:
b | e | s | T | ||
---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | |
t | 1 | 1 | 2 | 3 | 3 |
e | 2 | 2 | 1 | 2 | 3 |
s | 3 | 3 | 2 | 1 | 2 |
t | 4 | 4 | 3 | 2 | 1 |
Congratulations, you've successfully completed the matrix! The value in the bottom-right corner tells us that the edit distance between best
and test
is 1
, confirming that it would take a minimum of 1 edit to transform one string into the other.