Sketching, Streaming, and Fine-Grained Complexity of (Weighted) LCS

Karl Bringmann, Bhaskar Ray Chaudhury

The Longest Common Subsequence (LCS) problem is a fundamental challenge in computer science, essential for everything from genomic sequence alignment to version control systems like diff. Despite its ubiquity, LCS is notoriously difficult to scale. Standard algorithms require $O(n^2)$ time, and the Strong Exponential Time Hypothesis (SETH) suggests that a significantly faster general-purpose algorithm is unlikely to exist.

This research explores how to bypass these limitations in "big data" scenarios by focusing on two specific constraints: small, fixed alphabets (such as DNA's {A, C, G, T}) and the use of sketching or streaming models.

The Challenge of Sketching LCS

In sketching, we aim to compress a long string $x$ into a tiny summary (a "sketch") such that we can still determine if another string $y$ is a subsequence of $x$ of length at least $L$. Previous theoretical results suggested that sketching LCS was nearly impossible, requiring space almost proportional to the original string length. However, those "impossibility" proofs relied on the assumption of a massive, growing alphabet.

This paper demonstrates that when the alphabet size $|\Sigma|$ is small and fixed, the problem becomes much more tractable. The authors introduce a novel "permutation-based sketching" technique.

Algorithmic Approach: Permutation-Based Pruning

The core of the sketching method involves identifying "permutation strings"—sequences that contain every symbol of a specific subset of the alphabet at least once. By greedily identifying these structures, the algorithm prunes a string $x$ down to a core subsequence $C_L(x)$ that preserves all possible subsequences of length up to $L$.

Algorithm 1: Greedy computation of the core subsequence for sketching.

This pruning allows for a one-pass streaming algorithm that maintains counters for every possible subset of the alphabet. As the data flows, the sketch is updated in real-time using minimal memory.

Weighted LCS and Fine-Grained Complexity

Beyond standard LCS, the authors tackle the Weighted LCS (WLCS) problem, where each character is assigned a specific weight. They identify WLCS as belonging to a rare "intermediate" complexity class. While most string problems are either near-linear or quadratic, WLCS with a fixed alphabet has a complexity of $O(n + m^{|\Sigma|})$.

To achieve this, the authors combine their sketching techniques with Run-Length Encoding (RLE). They developed a dynamic programming recurrence that utilizes a "right-to-left maximum sequence" to skip redundant string segments, drastically improving performance over standard DP approaches.

Key Insights: Sketching as Compression

The fundamental insight is that to verify if a short string $y$ is a subsequence of a much longer string $x$, one does not need the entirety of $x$. Instead, one only needs to know the earliest possible locations where "milestone" subsequences can be completed.

Visual representation of mapping a target string to its occurrences within a compressed sketch.

By focusing on these milestones, the authors achieved a sketch size of $O(L^{|\Sigma|-1} \log L)$ bits. Crucially, they provided a matching lower bound, proving that this space complexity is nearly optimal.

Conclusion and Impact

This work settles the fine-grained complexity of Weighted LCS for fixed alphabets and provides practical bounds for sketching and streaming. While the exponential dependence on alphabet size $|\Sigma|$ means these methods are less suited for large character sets (like Unicode), they offer a powerful new toolkit for bioinformatics and binary data processing where alphabets are small and data volumes are massive.

Summary updated

BibTeX
@inproceedings{bringmann2018sketching,
  author = {Karl Bringmann and Bhaskar Ray Chaudhury},
  title = {{Sketching, Streaming, and Fine-Grained Complexity of (Weighted) LCS}},
  booktitle = {FSTTCS},
  year = {2018},
  doi = {10.4230/lipics.fsttcs.2018.40},
}
Figure