bully....maguire's blog

By bully....maguire, 5 years ago, In English

I don't have proof but i have gut feeling that , suppose s1 is string which needs to be converted to s2 then we can keep the largest common subsequence in s1 as it is and edit distance is number of elements we need to replace/remove/insert.

For example : s1 = "adjsjvnejnv"
              s2 = "djpppne"

Here LCS is "djne" , now we need to remove 3 element string "jnv" at right side of "djne" ,we can replace "sjv" with "ppp" in s1 and and we can delete "a" from s1. so total edit distance is 3+3+1 = 7 .

Idea is to replace or delete elements inbetween the elements of LCS and add or remove elements from right and left part of LCS .

I am not able to prove it . Can someone provide counterexample or proof ?

  • Vote: I like it
  • -30
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
Rev. 2   Vote: I like it +2 Vote: I do not like it

Yes it is. But Levenshtein distance is a whole bigger problem than just lcs (lcs allows only insertion & deletion)