Approximate Online Pattern Matching in Sub-linear Time

Diptarka Chakraborty, Debarati Das, Michal Koucký

Abstract

This research addresses a fundamental challenge in string algorithms: the approximate pattern matching problem under edit distance. For decades, the $O(nw)$ time complexity—where $n$ is the text length and $w$ is the pattern length—has remained a standard barrier. This paper introduces the first randomized algorithms to achieve sub-linear time relative to the pattern length for both offline and online settings, provided a constant-factor approximation is acceptable. By utilizing a grid graph representation and a novel "shortcut" technique, the authors demonstrate that it is possible to bypass the constraints suggested by the Strong Exponential Time Hypothesis (SETH) for exact matching.

Introduction

In classical pattern matching, the goal is to find exact occurrences of a pattern $P$ in a text $T$. However, real-world applications such as DNA sequencing, optical character recognition, and network traffic analysis frequently involve noise. To account for this, researchers use edit distance (Levenshtein distance), which measures the minimum number of insertions, deletions, or substitutions required to transform one string into another.

The objective is to compute, for every position $t$ in the text, the smallest edit distance $k_t$ between the pattern and any substring of the text ending at $t$. While Dynamic Programming (DP) provides an $O(nw)$ solution, recent theoretical developments suggest that significantly improving this for exact distance is likely impossible. This work explores whether settling for a constant-factor approximation allows for a breakthrough in computational efficiency.

The Grid Graph and Certified Boxes

The authors represent the pattern matching problem as a shortest-path problem in a "pattern matching graph." This grid-based representation maps the pattern against the text, where horizontal and vertical edges represent insertions or deletions (cost 1) and diagonal edges represent character matches (cost 0) or substitutions (cost 1).

To optimize the search, the algorithm identifies certified boxes. These are sub-regions of the DP grid where the edit distance is guaranteed to be below a specific threshold. Once identified, these boxes act as "shortcuts," allowing the algorithm to jump across large sections of the grid and avoid redundant cell-by-cell calculations.

Randomized Sampling and Density

Efficiently finding these shortcuts requires a randomized sampling strategy. The algorithm samples substrings of the pattern to identify "dense" regions—segments of the text that are highly similar to multiple parts of the pattern. By treating dense and sparse regions differently, the algorithm allocates computational resources more effectively, skipping ahead where matches are frequent and focusing effort where matching is more complex.

Online Pattern Matching and Succinct Space

The most significant contribution of the paper is the adaptation of these techniques to an online setting, where the text arrives one symbol at a time. This requires the algorithm to interleave the discovery of shortcuts with the calculation of the shortest path.

In this streaming context, memory is a critical constraint. The authors introduce a modified tree data structure to manage shortcuts, enabling the algorithm to operate in succinct space. This means the algorithm uses sub-linear extra space beyond the storage required for the pattern itself, making it viable for processing massive data streams where storing the entire text or a full DP table is impossible.

Key Results

The paper establishes new upper bounds for the complexity of approximate pattern matching:

  • Offline Algorithm: Achieves a constant-factor approximation of the edit distance sequence in $O(nw^{3/4})$ time, a major improvement over the traditional $O(nw)$.
  • Online Algorithm:
    • Time Complexity: Processes each text symbol in $O(w^{1-7/54})$ amortized time.
  • Space Complexity: Requires only $O(w^{1-1/54})$ extra space.
  • Accuracy: Guarantees a constant-factor multiplicative error with a small additive error term ($w^{8/9}$).

Both algorithms are randomized and proven to be correct with high probability (at least $1 - 1/n^3$).

Limitations and Future Directions

While these results represent a theoretical breakthrough, they involve specific trade-offs. The algorithms provide a constant-factor approximation rather than an exact distance. Furthermore, the online version introduces an additive error term that may be significant for very short patterns or cases requiring extremely high precision.

The complexity of the "interleaved" online algorithm also presents a hurdle for practical implementation compared to standard DP approaches. However, the authors suggest that the specific exponents achieved (e.g., $3/4$ and $7/54$) are likely not optimal and could be further refined by improving the shortcut selection process in future research.

Summary updated

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