Lune

STOC2020Top-tier venue

Approximating text-to-pattern Hamming distances

Timothy M. Chan, Shay Golan, Tomasz Kociumaka, Tsvi Kopelowitz, Ely Porat

Abstract

We revisit a fundamental problem in string matching: given a pattern of length m and a text of length n, both over an alphabet of size σ, compute the Hamming distance (i.e., the number of mismatches) between the pattern and the text at every location. Several randomized (1 + ε)-approximation algorithms have been proposed in the literature (e.g., by Karloff (Inf. Proc. Lett., 1993), Indyk (FOCS 1998), and Kopelowitz and Porat (SOSA 2018)), with running time of the form O(ε -O(1) n log n log m), all using fast Fourier transform (FFT). We describe a simple randomized (1 + ε)-approximation algorithm that is faster and does not need FFT. Combining our approach with additional ideas leads to numerous new results (all Monte-Carlo randomized) in different settings: 1. We obtain the first linear-time approximation algorithm; the running time is O(ε -2 n). In fact, the time bound can be made slightly sublinear in n if the alphabet size σ is small (by using bit packing tricks). 2. We apply our approximation algorithms to obtain a faster exact algorithm computing all Hamming distances up to a given threshold k; its running time is O(n+min( nk , nk 2 m )), which improves previous results by logarithmic factors and is linear if k ≤ √ m. 3. We alternatively obtain approximation algorithms with better ε-dependence, by using rectangular matrix multiplication. In fact, the time bound is O(n polylog n) when the pattern is sufficiently long, i.e., m ≥ ε -c for a specific constant c. Previous algorithms with the best ε-dependence require O(ε -1 n polylog n) time. 4. When k is not too small, we obtain a truly sublinear-time algorithm to find all locations with Hamming distance approximately (up to a constant factor) less than k, in O((n/k Ω(1) + occ)n o(1) ) time, where occ is the output size. The algorithm leads to a property tester for pattern matching, with high probability returning true if an exact match exists and false if the Hamming distance is more than δm at every location, running in O((δ -1/3 n 2/3 + δ -1 n m ) polylog n) time. 5. We obtain a streaming algorithm to report all locations with Hamming distance approximately less than k, using O(ε -2 √ k polylog n) space. Previously, streaming algorithms were known for the exact problem with O(k polylog n) space (which is tight up to the polylog n factor) or for the approximate problem with O(ε -O(1) √ m polylog n) space. For the special case of k = m, we improve the space usage to O(ε -1.5 √ m polylog n).

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

7 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Small-space and streaming pattern matching with k edits cites Faster Approximate Pattern Matching: A Unified Approach
  • New Applications of 3SUM-Counting in Fine-Grained Complexity and Pattern Matching cites Faster Algorithms for Text-to-Pattern Hamming Distances
  • Faster Pattern Matching under Edit Distance : A Reduction to Dynamic Puzzle Matching and the Seaweed Monoid of Permutation Matrices cites Faster Approximate Pattern Matching: A Unified Approach
  • Faster Pattern Matching under Edit Distance : A Reduction to Dynamic Puzzle Matching and the Seaweed Monoid of Permutation Matrices cites Small-space and streaming pattern matching with k edits
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers7

  1. Small-space and streaming pattern matching with kk editsTomasz Kociumaka, Ely Porat, Tatiana StarikovskayaFOCS 2021 · 13 citations
  2. Faster Pattern Matching under Edit Distance : A Reduction to Dynamic Puzzle Matching and the Seaweed Monoid of Permutation MatricesPanagiotis Charalampopoulos, Tomasz Kociumaka, Philip WellnitzFOCS 2022 · 8 citations
  3. Faster Algorithms for Text-to-Pattern Hamming DistancesTimothy M. Chan, Ce Jin, Virginia Vassilevska Williams, Yinzhan XuFOCS 2023 · 3 citations
  4. Faster Approximate Pattern Matching: A Unified ApproachPanagiotis Charalampopoulos, Tomasz Kociumaka, Philip WellnitzFOCS 2020 · 2 citations
  5. New Applications of 3SUM-Counting in Fine-Grained Complexity and Pattern MatchingNick Fischer, Ce Jin, Yinzhan XuSODA 2025 · 2 citations

Builds on1

  1. Faster Deterministic and Las Vegas Algorithms for Offline Approximate Nearest Neighbors in High DimensionsJosh Alman, Timothy M. Chan, R. Ryan WilliamsSODA 2020 · 9 citations

Related papers

  1. Near-Optimal Property Testers for Pattern MatchingCe Jin, Tomasz KociumakaFOCS 2025 · 1 citation
  2. Near-Optimal-Time Quantum Algorithms for Approximate Pattern MatchingTomasz Kociumaka, Jakob Nogler, Philip WellnitzSODA 2025 · 1 citation
  3. Almost-optimal sublinear-time edit distance in the low distance regimeKarl Bringmann, Alejandro Cassis, Nick Fischer, Vasileios NakosSTOC 2022 · 4 citations
  4. Sublinear-Time Algorithms for Computing & Embedding Gap Edit DistanceTomasz Kociumaka, Barna SahaFOCS 2020 · 9 citations
  5. Space-Efficient k-Mismatch Text IndexesTomasz Kociumaka, Jakub RadoszewskiSODA 2026 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines