Algorithmica

, Volume 1, Issue 1, pp 251–266

AnO(ND) difference algorithm and its variations

Authors

  • Eugene W. Myers
    • Department of Computer ScienceUniversity of Arizona
Article

DOI: 10.1007/BF01840446

Cite this article as:
Myers, E.W. Algorithmica (1986) 1: 251. doi:10.1007/BF01840446

Abstract

The problems of finding a longest common subsequence of two sequencesA andB and a shortest edit script for transformingA intoB have long been known to be dual problems. In this paper, they are shown to be equivalent to finding a shortest/longest path in an edit graph. Using this perspective, a simpleO(ND) time and space algorithm is developed whereN is the sum of the lengths ofA andB andD is the size of the minimum edit script forA andB. The algorithm performs well when differences are small (sequences are similar) and is consequently fast in typical applications. The algorithm is shown to haveO(N+D2) expected-time performance under a basic stochastic model. A refinement of the algorithm requires onlyO(N) space, and the use of suffix trees leads to anO(N logN+D2) time variation.

Key words

Longest common subsequenceShortest edit scriptEdit graphFile comparison
Download to read the full article text

Copyright information

© Springer-Verlag New York Inc. 1986