This site is supported by donations to The OEIS Foundation.

Levenshtein distance

From OeisWiki
(Redirected from Edit distance)
Jump to: navigation, search


This article page is a stub, please help by expanding it.


In information theory and computer science, the Levenshtein distance is either

It is named after Vladimir Levenshtein, who considered this distance in 1965.[1] The term edit distance is often used to refer specifically to Levenshtein distance.

Levenshtein distance between two strings

The Levenshtein distance between two strings (or string edit distance) is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being

  • insertion (of a single character),
  • deletion (of a single character), or
  • substitution (of a single character).

Examples (strings)

For example, the Levenshtein distance between "kitten" and "sitting" is 3, since the following three edits change one into the other, and there is no way to do it with fewer than three edits:

  1. kitten → sitten (substitution of 's' for 'k')
  2. sitten → sittin (substitution of 'i' for 'e')
  3. sittin → sitting (insertion of 'g' at the end).

For example, the Levenshtein distance between "{2, 3, 5, 8, 13}" and "{2, 3, 5, 7, 11}" is 2, since the following two edits change one into the other, and there is no way to do it with fewer than two edits:

  1. {2, 3, 5, 8, 13} → {2, 3, 5, 7, 13} (substitution of '7' for '8')
  2. {2, 3, 5, 7, 13} → {2, 3, 5, 7, 11} (substitution of '1' for '3')

Levenshtein distance between two trees

The Levenshtein distance between two trees (or tree edit distance) is defined as the minimum number of edits needed to transform one tree into the other, with the allowable edit operations being

  • insertion (of a single node),
  • deletion (of a single node), or
  • substitution (of a single node).

Notes

  1. В.И. Левенштейн (1965). “Двоичные коды с исправлением выпадений, вставок и замещений символов”. Доклады Академий Наук СCCP 163 (4): pp. 845–8.  Appeared in English as: Levenshtein VI (1966). “Binary codes capable of correcting deletions, insertions, and reversals”. Soviet Physics Doklady 10: pp. 707–10. 

External links