The Column for Letter "E"
Now that we've filled in the column for the letter B
, let's move on to the column for the letter E
from the string best
.
Calculating the Costs
Starting with E
and T
, we again find that the two letters are different, so the edit cost is 1
. Here are the calculations for the cell:
- From Above: (1 + 1 = 2)
- From the Left: (2 + 1 = 3)
- From the Diagonal: (1 + 1 = 2)
The minimum of these is 2
, so we place it in the cell where E
intersects with T
.
Next, we move to E
and e
. The two letters are the same, so the edit cost is 0
. The calculations for this cell are:
- From Above: (2 + 1 = 3)
- From the Left: (1 + 1 = 2)
- From the Diagonal: (0 + 1 = 1)
The minimum is 1
, so we place it in the cell where E
intersects with e
.
The Updated Matrix
Here's how our matrix looks after filling in the "E" column:
b | E | s | t | ||
---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | |
T | 1 | 1 | 2 | ||
e | 2 | 2 | 1 | ||
s | 3 | 3 | 2 | ||
t | 4 | 4 | 3 |
We've successfully filled in the second column for the letter E
. As before, we'd continue this process for the remaining columns to complete the matrix and find the total edit distance.