mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-06 17:44:08 +08:00
Vectorize images for Levenshtein Distance.
This commit is contained in:
@ -62,7 +62,7 @@ is being calculated based on three previously possible transformations.
|
|||||||
|
|
||||||
To explain this further let’s draw the following matrix:
|
To explain this further let’s draw the following matrix:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- Cell `(0:1)` contains red number 1. It means that we need 1 operation to
|
- Cell `(0:1)` contains red number 1. It means that we need 1 operation to
|
||||||
transform `M` to an empty string. And it is by deleting `M`. This is why this number is red.
|
transform `M` to an empty string. And it is by deleting `M`. This is why this number is red.
|
||||||
@ -89,11 +89,11 @@ letters in `i`'s row and `j`'s column.
|
|||||||
|
|
||||||
You may clearly see the recursive nature of the problem.
|
You may clearly see the recursive nature of the problem.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's draw a decision graph for this problem.
|
Let's draw a decision graph for this problem.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
You may see a number of overlapping sub-problems on the picture that are marked
|
You may see a number of overlapping sub-problems on the picture that are marked
|
||||||
with red. Also there is no way to reduce the number of operations and make it
|
with red. Also there is no way to reduce the number of operations and make it
|
||||||
@ -106,7 +106,7 @@ bottom-up direction) is being applied here.
|
|||||||
Applying this principle further we may solve more complicated cases like
|
Applying this principle further we may solve more complicated cases like
|
||||||
with `Saturday → Sunday` transformation.
|
with `Saturday → Sunday` transformation.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user