Streaming with Oracle: New Streaming Algorithms for Edit Distance and LCS

Alireza Farhadi, MohammadTaghi Hajiaghayi, Aviad Rubinstein, Saeed Seddighin

Abstract

This paper introduces the first constant-factor approximation algorithm for Edit Distance (ED) in the asymmetric streaming model that utilizes sub-polynomial memory ($O(n^\delta)$). By leveraging the triangle inequality and a recursive decomposition strategy, the authors demonstrate how to trade exponential runtime for significant memory savings. This approach provides a new framework for comparing massive strings, such as genomic sequences, in memory-constrained environments.

Introduction

Measuring similarity between strings is fundamental to computer science, primarily through Edit Distance (ED)—the minimum edits required to transform one string into another—and Longest Common Subsequence (LCS). However, as data scales to billions of base pairs, classic $O(n^2)$ time and $O(n)$ space algorithms become impractical.

The authors address this by focusing on the asymmetric streaming model. In this setting, one string (the "offline" string) is stored with random access, while the second (the "online" string) arrives as a single-pass stream. The goal is to approximate similarity using minimal working memory. Prior to this work, efficient streaming algorithms were generally limited to cases where the distance between strings was already very small.

Methodology: The Triangle Inequality and Recursive Decomposition

The core innovation is a strategy that uses the triangle inequality to reduce space complexity. Instead of calculating distances between the stream and every possible offline substring, the algorithm employs a "Closest Substring" strategy.

Visual representation of the string decomposition and matching strategy used to approximate distances.
  1. Windowing: The incoming stream is partitioned into windows.
  2. Mapping: For each window, the algorithm identifies the most similar substring in the offline string.
  3. Compression: Rather than storing the window data, the algorithm stores only the coordinates and the distance to the "best" substring.
  4. Triangle Inequality: By knowing the distance from a window $w$ to substring $A$, and calculating the distance between $A$ and another substring $B$ via random access, the algorithm approximates the distance from $w$ to $B$ without needing $w$ in memory.

To achieve sub-polynomial memory ($O(n^\delta)$), this logic is applied recursively across multiple levels, breaking the problem into increasingly smaller fragments. This reduction significantly lowers memory usage but causes the approximation error to grow and the runtime to increase exponentially relative to $1/\delta$.

Key Results and Theoretical Bounds

The paper establishes several new upper bounds for memory usage in the asymmetric streaming model. Notably, all proposed algorithms are deterministic, avoiding the failure probabilities associated with stochastic sketching or hashing methods.

Summary of approximation factors and memory bounds for various string similarity problems.

The results for LCS are particularly significant as they match known lower bounds, proving the optimality of the $\tilde{O}(\sqrt{n})$ memory requirement for a $(1-\epsilon)$-approximation. Additionally, the framework generalizes to improve bounds for related problems such as Distance to Monotonicity (DTM) and Longest Increasing Subsequence (LIS).

Discussion and Limitations

While the memory savings are substantial, they come with a "Savitch-like" trade-off: the constant-factor approximation for ED requires runtime that is exponential in $1/\delta$. This may limit practical application for extremely small $\delta$ values where processing time becomes prohibitive.

Furthermore, the model's reliance on random access to one string means it does not directly translate to "double-stream" scenarios where both strings are online. Finally, while LCS bounds are tight, a theoretical gap remains for $(1+\epsilon)$-ED approximations, presenting a clear path for future research in closing the gap between $O(\sqrt{n})$ memory and known lower bounds.

Summary updated

BibTeX
@misc{farhadi2020streaming,
  author = {Alireza Farhadi and MohammadTaghi Hajiaghayi and Aviad Rubinstein and Saeed Seddighin},
  title = {{Streaming with Oracle: New Streaming Algorithms for Edit Distance and LCS}},
  year = {2020},
  eprint = {2002.11342},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.11342},
}
Figure