A fast longest common subsequence algorithm for similar strings

  • Authors:
  • Abdullah N. Arslan

  • Affiliations:
  • Department of Computer Science and Information Systems, Texas A & M University - Commerce, TX

  • Venue:
  • LATA'10 Proceedings of the 4th international conference on Language and Automata Theory and Applications
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

Abstract

The longest common subsequence problem is a very important computational problem for which there are many algorithms. We present a new algorithm for this problem. Let X and Y be any two given strings each of length O(n). We observe that a longest common subsequence can be obtained by using longest common prefixes of suffixes (longest common extensions) of X and Y. The longest common extension problem asks for the longest common prefix of suffixes starting in a given pair of positions in X and Y, respectively. Let e be the number of edit operations, insert, delete, and substitute to change X to Y (i.e. let e be the edit distance between X and Y). Our algorithm visits $O(\min\{en,(1+\sqrt{2})^{2e+1})$ nodes in the edit graph, and for every visited node, performs one longest common extension query. Each of these queries can be answered in constant time if we represent the strings by a suffix tree or a suffix array. These data structures can be created in linear time. We do not assume that the edit distance e is known beforehand, therefore we try values for e starting with e=1 (without loss of generality X≠Y) and double e until our algorithm finds a longest common subsequence. The total time complexity of our algorithm is $O(\min\{en\log{n},n+e(1+\sqrt{2})^{2e+1}\})$. This is a better time complexity result compared to those of existing solutions for the problem when e is small. For example, when $e\leq \frac{1}{3}((\log_{(1+\sqrt{2})}~{n})-1)$ our algorithm finds an optimal solution in time O(n).