Starting from "abcd", I want to go to "badc" :
It's 4 operations. I can't find out a shorter way to do it. However, Levenshtein distance returns me a cost of 3. Why is that?
Thanks for your response.
You can go from abcd
to badc
in 3 operations. Remember you can do insertions, deletions and substitutions:
a
-> bcd
.c
with a
-> bad
.c
at the end -> badc
.More generally, an insert + remove pair of operations can be coalesced into a substitution if the insertion and the removal are adjacent.