Papers
Topics
Authors
Recent
Search
2000 character limit reached

Longest Common Subsequence (LCS)

Updated 5 July 2026
  • Longest Common Subsequence (LCS) is defined as the longest sequence that appears in all input strings in the same order, though not necessarily contiguously.
  • Efficient LCS algorithms use dynamic programming, sparse matching, and approximation techniques to mitigate complexity, especially in NP-hard multi-string cases.
  • LCS has broad applications in bioinformatics, text editing, data compression, and error detection, making it a cornerstone in string analysis.

to=arxiv_search 天天中彩票中奖json code tool_call_id="search1" {"query":"Longest Common Subsequence arXiv approximation sparse random binary sequences", "max_results": 10, "sort_by": "submittedDate", "sort_order": "descending"} to=arxiv_search аанацҳауеитjson code tool_call_id="search1" {"query":"Longest Common Subsequence arXiv approximation sparse random binary sequences", "max_results": 10, "sort_by": "submittedDate", "sort_order": "descending"} to=arxiv_search 中国福利彩票天天json code {"query":"Longest Common Subsequence arXiv approximation sparse random binary sequences", "max_results": 10, "sort_by": "submittedDate", "sort_order": "descending"} The Longest Common Subsequence (LCS) problem asks for a sequence of maximum length that appears, in the same relative order, as a subsequence of each input string. In its classical two-string form, LCS is a foundational problem in stringology with applications including text compression, error-detecting codes, biological sequence comparison, text editing, and large-scale sequence similarity analysis (0911.5031, Abdi et al., 2022). The two-string problem admits polynomial-time dynamic programming, whereas the problem becomes NP-hard for an arbitrary number of strings, which is why the literature now spans exact algorithms, sparse and parallel formulations, approximation algorithms, statistical limit theory, and a large family of constrained and generalized variants (Vahidi et al., 2023, Cao et al., 2020).

1. Formal definition and classical formulation

For strings X=x1x2xnX=x_1x_2\cdots x_n and Y=y1y2ymY=y_1y_2\cdots y_m, a string Z=z1z2ztZ=z_1z_2\cdots z_t is a common subsequence if there exist increasing index sequences in both strings whose selected characters spell ZZ (Chowdhury et al., 2011). The optimization target is to maximize tt.

The standard dynamic-programming formulation uses prefix subproblems. For random binary sequences, Dixon writes l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j) for the LCS length of the length-ii and length-jj prefixes and recalls the recurrence

$l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$

with boundary conditions l(i,0)=l(0,j)=0l(i,0)=l(0,j)=0 (Dixon, 2013). In the classical two-string setting, this yields an Y=y1y2ymY=y_1y_2\cdots y_m0-time exact algorithm (Vahidi et al., 2023).

A persistent source of confusion is the difference between subsequence and substring. A subsequence preserves order but need not be contiguous, whereas a substring must be contiguous; the distinction is crucial because many LCS variants modify exactly this structural requirement (Ueki et al., 2016, Abdi et al., 2022). A second common misconception is complexity-related: NP-hardness in the supplied literature refers to the arbitrary-Y=y1y2ymY=y_1y_2\cdots y_m1 or multi-string setting, not to the ordinary two-string problem (Vahidi et al., 2023, Abdi et al., 2022).

The LCS problem also admits alternative structural views. One is the poset formulation: if

Y=y1y2ymY=y_1y_2\cdots y_m2

ordered by

Y=y1y2ymY=y_1y_2\cdots y_m3

then chains in Y=y1y2ymY=y_1y_2\cdots y_m4 correspond exactly to common subsequences, and the longest chain has length Y=y1y2ymY=y_1y_2\cdots y_m5 (Dixon, 2013). Another is the relation to insertion/deletion edit distance: Y=y1y2ymY=y_1y_2\cdots y_m6 which is central in several approximation arguments (Akmal et al., 2021).

2. Exact algorithms, sparsity, and complexity barriers

The exact-time landscape is unusually rigid. For two strings of length Y=y1y2ymY=y_1y_2\cdots y_m7, standard dynamic programming is quadratic, and the fastest exact algorithm cited in the supplied literature is the Masek–Paterson algorithm running in

Y=y1y2ymY=y_1y_2\cdots y_m8

(Akmal et al., 2021). Fine-grained complexity results based on SETH are cited as strong evidence that truly subquadratic exact algorithms are unlikely in general (Boneh et al., 30 Jul 2025, Akmal et al., 2021). This has shifted a substantial part of the literature toward structure-sensitive exact algorithms and toward approximation.

One major exact direction is the sparse-match regime. Let

Y=y1y2ymY=y_1y_2\cdots y_m9

and let Z=z1z2ztZ=z_1z_2\cdots z_t0 denote the LCS length. In this formulation, LCS becomes the problem of finding the longest increasing chain among matched pairs (Zhu et al., 2015). The paper “A Practical Z=z1z2ztZ=z_1z_2\cdots z_t1 time Algorithm for Computing the Longest Common Subsequence” reformulates the sparse LCS computation as maintenance of an ordered set Z=z1z2ztZ=z_1z_2\cdots z_t2 of breakpoints of a nondecreasing prefix-optimum function Z=z1z2ztZ=z_1z_2\cdots z_t3, with a single update primitive Z=z1z2ztZ=z_1z_2\cdots z_t4 (Zhu et al., 2015). That yields three exact implementations: Z=z1z2ztZ=z_1z_2\cdots z_t5 with the first using a van Emde Boas tree, the second a balanced binary search tree, and the third an ordered vector (Zhu et al., 2015). This is significant because it replaces dense Z=z1z2ztZ=z_1z_2\cdots z_t6 dynamic programming by algorithms parameterized by match sparsity and by the answer length.

Parallel exact LCS has also been studied, although the supplied implementation paper is explicitly a systems contribution rather than a new complexity result. “Parallel Longest Common SubSequence Analysis In Chapel” implements a two-string parallel LCS algorithm in Chapel and integrates it into Arkouda, recasting LCS as a maximum-weight path problem on a grid graph and using recursive decomposition, monotone matrix search, and prefix-style primitives rather than a conventional anti-diagonal DP (Vahidi et al., 2023).

3. Probabilistic, asymptotic, and statistical theory

A large probabilistic literature treats LCS length itself as a random variable. For two random binary sequences Z=z1z2ztZ=z_1z_2\cdots z_t7 and Z=z1z2ztZ=z_1z_2\cdots z_t8 of lengths Z=z1z2ztZ=z_1z_2\cdots z_t9 and ZZ0, Dixon writes

ZZ1

and studies the limit profile

ZZ2

(Dixon, 2013). The classical equal-length constant

ZZ3

is the binary Chvátal–Sankoff constant. The paper states the then-best known bounds

ZZ4

and reports simulations up to ZZ5 with

ZZ6

(Dixon, 2013).

The function ZZ7 organizes the unequal-length theory. It satisfies the symmetry relation

ZZ8

is increasing, and is concave; consequently it is continuous, has left and right derivatives at every point, and those one-sided derivatives are monotone decreasing (Dixon, 2013). The paper also derives exact outer regimes: ZZ9 so the nontrivial region is tt0 (Dixon, 2013).

Concentration is already visible at the equal-length level. By Azuma–Hoeffding,

tt1

which shows tt2-scale concentration around the mean for random binary strings (Dixon, 2013). More globally, the same paper states uniform concentration of the whole prefix-length profile tt3 around tt4.

The statistical use of LCS as a similarity score is explicit in “Simulations, Computations, and Statistics for Longest Common Subsequences.” That work studies tt5, tt6, and proposes a hypothesis test based on

tt7

for testing whether two observed sequences are unusually similar under an i.i.d. null (Liu et al., 2017). It also estimates, for alphabet size tt8,

tt9

using Monte Carlo under the null model (Liu et al., 2017).

Variance remains controversial. The Monte Carlo study in (Liu et al., 2017) conjectures

l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)0

whereas the simulation-driven assessment in (Ning et al., 2013) reports values interpreted as suggesting

l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)1

for two binary sequences and presents this as a conjecture from simulation rather than a theorem. This suggests that the asymptotic order of the variance remained unsettled in the supplied sources.

A further probabilistic variant is the repetition-free LCS, where each symbol may appear at most once. For two random length-l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)2 sequences over a l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)3-ary alphabet, the paper (Kiwi et al., 2013) shows three asymptotic regimes: if l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)4, then

l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)5

if l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)6, then

l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)7

and if l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)8, then

l(i,j)=L(Xi,Yj)l(i,j)=L(X_i,Y_j)9

(Kiwi et al., 2013). This places a duplication-sensitive variant of LCS into a sharply different occupancy-style asymptotic regime.

4. Approximation and near-linear algorithms

Approximation has become central because exact quadratic-time barriers appear robust. The paper “Approximating LCS in Linear Time: Beating the ii0 Barrier” gives a randomized linear-time algorithm with approximation factor

ii1

in expectation, thereby beating the previously known linear-time ii2 baseline (Hajiaghayi et al., 2020). Its analysis decomposes instances into regimes based on optimum size, match sparsity, alphabet frequency structure, and block-level behavior, combining sampling, sparse matching-pair representations, a block DP, and a semi-permutation/random-shift method (Hajiaghayi et al., 2020).

For small alphabets, the trivial baseline is the unary ii3 approximation obtained by returning the most frequent common symbol. “Improved Approximation for Longest Common Subsequence over Small Alphabets” shows two structural results: first, if a ii4 approximation is achievable for binary LCS in truly subquadratic time on unequal-length inputs, then for every constant ii5 there is a truly subquadratic-time algorithm achieving a ii6 approximation for ii7-ary LCS; second, for every constant ii8, equal-length ii9-ary instances already admit a truly subquadratic-time jj0 approximation (Akmal et al., 2021). In the paper’s terms, this means the binary case is the hardest.

A more recent result is deterministic. “Deterministic Longest Common Subsequence Approximation in Near-Linear Time” gives a deterministic algorithm returning an

jj1

approximation in near-linear time for general alphabets and states that this is the first deterministic near-linear-time LCS approximation with a sublinear approximation ratio in the unrestricted-alphabet setting (Boneh et al., 30 Jul 2025). Its method combines a best single-symbol subsequence, LIS under symbol orders induced by one string, Greedy LDS peeling, and logarithmic frequency bucketing (Boneh et al., 30 Jul 2025).

These approximation results clarify another common misconception: SETH-based barriers constrain exact subquadratic algorithms, but they do not preclude nontrivial approximation in near-linear or truly subquadratic time (Boneh et al., 30 Jul 2025, Akmal et al., 2021).

5. Variants, constraints, and structural generalizations

A large fraction of the LCS literature studies variants in which the feasible subsequences satisfy additional global structure.

The Longest Common Cyclic Subsequence problem generalizes LCS to cyclic strings, maximizing over circular shifts. The cited result gives an jj2 algorithm for two strings of length jj3 by reducing all cyclic shifts of one string to windows in the doubled string and reusing a single dynamic-programming structure (0911.5031).

The Longest Common Palindromic Subsequence problem adds a palindromicity constraint. For two strings of length jj4, (Chowdhury et al., 2011) defines a 4-dimensional DP

jj5

for substrings jj6 and jj7, yielding an

jj8

time algorithm, and also gives a geometric reformulation via nested rectangles and 4-dimensional chains with running time

jj9

where $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$0 is the number of matches (Chowdhury et al., 2011). This is a clear example of how a seemingly mild structural restriction can force a jump from the ordinary 2-parameter LCS state space to a 4-parameter one.

The substring-excluding constrained LCS problem, STR-EC-LCS, seeks a longest common subsequence of $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$1 and $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$2 that does not contain a forbidden pattern $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$3 as a substring. The cited algorithm combines a Nakatsu-style “shortest prefix of $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$4” DP with KMP-style overlap states and achieves

$l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$5

time and space, where $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$6 is the constrained LCS length and $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$7 (Yamada et al., 2020).

The paper “Longest Common Subsequence in $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$8-length substrings” defines LCSk, where the subsequence is composed of non-overlapping matching substrings of fixed length $l(i,j)= \begin{cases} l(i-1,j-1)+1,&\text{if }X_i\text{ and }Y_j\text{ end in the same symbol},\[2mm] \max\{l(i,j-1),\,l(i-1,j)\},&\text{if }X_i\text{ and }Y_j\text{ end in different symbols}, \end{cases}$9. It gives an l(i,0)=l(0,j)=0l(i,0)=l(0,j)=00-time algorithm and l(i,0)=l(0,j)=0l(i,0)=l(0,j)=01-space computation for equal-length strings, with ordinary LCS recovered as the special case l(i,0)=l(0,j)=0l(i,0)=l(0,j)=02 (Benson et al., 2014). A related but stricter family appears in (Ueki et al., 2016), which studies LCS in at least l(i,0)=l(0,j)=0l(i,0)=l(0,j)=03-length substrings and its order-isomorphic generalization. There, both the exact-match and order-isomorphic variants admit l(i,0)=l(0,j)=0l(i,0)=l(0,j)=04-time algorithms, but the order-isomorphic version requires op-LCE preprocessing and semi-dynamic RMQ rather than the simple longest-common-suffix recurrences available in the exact case (Ueki et al., 2016).

These variants collectively show that the phrase “LCS” now names not a single problem but a broad design pattern: preserve order, then alter the admissible local structure—cyclicity, palindromicity, forbidden substrings, exact l(i,0)=l(0,j)=0l(i,0)=l(0,j)=05-blocks, order-isomorphic blocks, or distinct-symbol constraints—and the algorithmic state space changes accordingly.

6. Multiple-string LCS and heuristic ecosystems

For an arbitrary number of strings, exact LCS is NP-hard, so heuristic and hyper-heuristic systems occupy much of the practical literature (Cao et al., 2020, Abdi et al., 2022). One line attacks the problem indirectly through related objects. “A Fast Randomized Algorithm for Finding the Maximal Common Subsequences” samples maximal common subsequences (MCSs) of l(i,0)=l(0,j)=0l(i,0)=l(0,j)=06 strings rather than exact LCSs, with one run costing

l(i,0)=l(0,j)=0l(i,0)=l(0,j)=07

or l(i,0)=l(0,j)=0l(i,0)=l(0,j)=08 for equal-length strings, and argues theoretically and empirically that the longest MCS seen over repeated runs often yields an LCS (Cao et al., 2020).

Another line develops direct heuristics for large multi-string instances. The Deposition and Extension Algorithm (DEA) first constructs a template common subsequence by deposition and then enlarges it by extension, with overall complexity

l(i,0)=l(0,j)=0l(i,0)=l(0,j)=09

and the paper reports that DEA is better than Long Run and often better than Expansion, especially on many long sequences (0903.2015). More recent beam-search work formalizes heuristic scoring. “Longest Common Subsequence: Tabular vs. Closed-Form Equation Computation of Subsequence Probability” replaces a tabular recurrence for the probability Y=y1y2ymY=y_1y_2\cdots y_m00 by the closed form

Y=y1y2ymY=y_1y_2\cdots y_m01

then uses that to define analytic residual-length heuristics and a Coefficient-of-Variation-based heuristic inside beam search for multi-string LCS (Abdi et al., 2022).

Hyper-heuristic selection has also become explicit. “Longest Common Substring in Longest Common Subsequence’s Solution Service” introduces Y=y1y2ymY=y_1y_2\cdots y_m02, a stochastic classifier that uses local longest common substring lengths to label an input set as correlated or uncorrelated, and then uses that label plus a normalized upper bound to choose among Y=y1y2ymY=y_1y_2\cdots y_m03-Ex, Y=y1y2ymY=y_1y_2\cdots y_m04, and GCoV (Abdi et al., 2022). This suggests a broader practical trend: for multi-string LCS, solver selection based on instance structure may be as important as the design of any single heuristic.

A plausible implication is that multi-string LCS now has two distinct literatures: a complexity-theoretic one centered on NP-hardness, and an engineering-oriented one centered on robust heuristic pipelines. The supplied papers show both strands clearly, but they do not collapse into a single dominant methodology.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (18)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Longest Common Subsequence (LCS).