Approximate Online Pattern Matching in Sublinear Time

Diptarka Chakraborty, Debarati Das, Michal Koucký

TL;DR

This paper introduces novel algorithms for approximate pattern matching with edit distance, achieving significant speedups in both offline and online settings. For the first time, an online algorithm offers sublinear time and space complexity relative to the pattern length, providing a constant-factor approximation with a bounded additive error.

What Problem Does This Paper Address?

The core problem is approximate pattern matching under edit distance. Imagine you have a long text (like a DNA sequence or a large document) and a shorter pattern (a gene or a search query). You want to find all locations in the text where a substring is "close" to the pattern, meaning it can be transformed into the pattern using a small number of edits (insertions, deletions, substitutions). This is crucial for applications like bioinformatics, spell checking, and data retrieval.

While exact pattern matching is well-studied, approximate matching is more challenging. The standard dynamic programming approach to find all approximate matches takes $O(nm)$ time, where $n$ is the text length and $m$ is the pattern length. This is too slow for very large texts. Researchers have been trying to improve this, especially by finding approximations to the exact edit distance rather than the exact value itself.

A key challenge is the online setting, where the text arrives character by character. In this scenario, we need to provide an approximate match score for each incoming character without knowing the rest of the text, and crucially, with limited memory (sublinear in pattern length). Previous online algorithms often had high time or space complexity, or relied on specific distance metrics. This paper aims to break these barriers for edit distance.

Methods

The paper presents two main algorithmic contributions:

  • Offline Algorithm: For the case where both the pattern and the entire text are available, they develop a randomized algorithm that computes an approximate edit distance for all text positions. This algorithm achieves a running time of $\tilde{O}(nm^{3/4})$, a significant improvement over the $O(nm)$ baseline. The core idea builds upon existing techniques for approximating edit distance in sub-quadratic time, adapting them to the pattern matching problem by cleverly constructing and analyzing "dynamic programming graphs" and using "certified boxes" to represent approximate matches.
  • Online Algorithm: This is the more groundbreaking contribution. They design a randomized algorithm that processes the text symbol by symbol. For each incoming character, it outputs an approximate edit distance score. This algorithm achieves an amortized time of $\tilde{O}(m^{1 - 7/54})$ per symbol and uses $\tilde{O}(m^{1 - 1/54})$ additional space (beyond storing the pattern). This is the first algorithm to achieve sublinear time and space complexity relative to the pattern length in the online setting for approximate pattern matching with edit distance. The approach involves interleaving phases of a "covering algorithm" (to identify potential matches) and a "min-cost path algorithm" (to refine these matches), carefully adapting them for the streaming and limited-space constraints.

Both algorithms rely on randomization and provide correct answers with high probability. They also leverage the concept of "certified boxes" and "shortcuts" in grid graphs, which are standard tools in edit distance approximation algorithms.

Datasets

Not discussed in the paper. The algorithms are theoretical and designed to work on any text and pattern strings.

Key Insights and Ideas

  • Bridging the Gap in Online Matching: The most significant insight is the development of an online algorithm that breaks the $O(m)$ time and space barrier per symbol, which was a major hurdle for practical streaming applications.
  • Interleaving Offline Techniques for Online Constraints: The online algorithm cleverly adapts techniques developed for offline edit distance approximation (like covering and min-cost path algorithms) to the strict constraints of streaming data and limited memory. This requires careful modification to handle the sequential arrival of text symbols.
  • The Power of Approximation: The paper demonstrates that for many applications, a constant-factor approximation with a bounded additive error is sufficient and allows for dramatic performance improvements.
  • "Certified Boxes" as Building Blocks: The concept of "certified boxes" (subgraphs with bounded costs) is crucial for both algorithms. They serve as a way to efficiently represent and combine potential approximate matches.

Key Results

  • Offline Algorithm: Achieves a $\tilde{O}(nm^{3/4})$ time complexity for computing a constant-factor approximation of approximate pattern matching.
  • Online Algorithm:
    • Provides a $(c, m^{8/9})$-approximation (constant multiplicative error $c$, and $m^{8/9}$ additive error).
  • Runs in $\tilde{O}(m^{1 - 7/54})$ amortized time per symbol.
  • Uses $\tilde{O}(m^{1 - 1/54})$ additional space.
  • This is the first algorithm to achieve sublinear time and space complexity relative to the pattern length in the online setting for edit distance.

Limitations and Future Work

  • High Edit Distance Limitation: The paper notes that the online algorithm's efficiency is most pronounced when the edit distance is "high" (relative to $m$). For very small edit distances, the performance might not be as dramatically improved.
  • Open Problem: The authors explicitly state an "Open Problem": extending the online approximation algorithm to work efficiently for the full range of edit distances (not just high ones), which would be of great theoretical and practical interest.

Summary updated

BibTeX
@inproceedings{chakraborty2019approximate,
  author = {Diptarka Chakraborty and Debarati Das and Michal Koucký},
  title = {{Approximate Online Pattern Matching in Sublinear Time}},
  booktitle = {FSTTCS},
  year = {2019},
  url = {https://openreview.net/forum?id=bbz4alUx8S},
}
Figure