The Column for Letter "S"
Having filled the columns for B
and E
, let's now move on to the column for the letter S
from the string best
.
Calculating the Costs for "S"
Starting with S
and T
, we find that the two letters are different, so the edit cost is 1
. The calculations for this cell are:
- From Above: (2 + 1 = 3)
- From the Left: (2 + 1 = 3)
- From the Diagonal: (2 + 1 = 3)
The minimum of these is 3
, so we place it in the cell where S
intersects with T
.
The Updated Matrix with "S" Column Filled
Here's how our matrix looks after filling in the "S" column:
b | e | S | t | ||
---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | |
T | 1 | 1 | 2 | 3 | |
e | 2 | 2 | 1 | 2 | |
s | 3 | 3 | 2 | 1 | |
t | 4 | 4 | 3 | 2 |
With the column for S
filled in, we're getting closer to completing our matrix. We would continue this step-by-step approach for the remaining columns to determine the final edit distance between the two strings.