English

Fast and Simple Computation of All Longest Common Subsequences

Data Structures and Algorithms 2011-03-09 v2

Abstract

This paper shows that a simple algorithm produces the {\em all-prefixes-LCSs-graph} in O(mn)O(mn) time for two input sequences of size mm and nn. Given any prefix pp of the first input sequence and any prefix qq of the second input sequence, all longest common subsequences (LCSs) of pp and qq can be generated in time proportional to the output size, once the all-prefixes-LCSs-graph has been constructed. The problem can be solved in the context of generating all the distinct character strings that represent an LCS or in the context of generating all ways of embedding an LCS in the two input strings.

Keywords

Cite

@article{arxiv.cs/0211001,
  title  = {Fast and Simple Computation of All Longest Common Subsequences},
  author = {Ronald I. Greenberg},
  journal= {arXiv preprint arXiv:cs/0211001},
  year   = {2011}
}

Comments

LaTeX 8 pages, 4 figures, corrected typos (especially in pseudocode in Figure 4)

R2 v1 2026-07-22T12:20:21.818Z