Faster Algorithms for Text-to-Pattern Hamming Distances
Timothy M. Chan, Ce Jin, Virginia Vassilevska Williams, Yinzhan Xu
Abstract
We study the classic Text-to-Pattern Hamming Distances problem: given a pattern P of length m and a text T of length n, both over a polynomial-size alphabet, compute the Hamming distance between P and for every shift i, under the standard Word-RAM model with -bit words.•We provide an time Las Vegas randomized algorithm for this problem, beating the decades-old running time [Abrahamson, SICOMP 1987]. We also obtain a deterministic algorithm, with a slightly higher running time. Our randomized algorithm extends to the k-bounded setting, with running time , removing all the extra logarithmic factors from earlier algorithms [Gawrychowski and Uznanski, ICALP 2018; Chan, Golan, Kociumaka, Kopelowitz and Porat, STOC 2020].•For the -approximate version of Text-to-Pattern Hamming Distances, we give an time Monte Carlo randomized algorithm (where hides poly-logarithmic factors), beating the previous running time [Kopelowitz and Porat, FOCS 2015; Kopelowitz and Porat, SOSA 2018].Our approximation algorithm exploits a connection with 3SUM, and uses a combination of Fredman’s trick, equality matrix product, and random sampling; in particular, we obtain new results on approximate counting versions of 3 SUM and Exact Triangle, which may be of independent interest. Our exact algorithms use a novel combination of hashing, bit-packed FFT, and recursion; in particular, we obtain a faster algorithm for computing the sumset of two integer sets, in the regime when the universe size is close to quadratic in the number of elements. We also prove a fine-grained equivalence between the exact Text-to-Pattern Hamming Distances problem and a range-restricted, counting version of 3 SUM.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 60f0f71a-8b77-4451-bb9e-fb81cbb68315Cited by top-tier papers4
- New Applications of 3SUM-Counting in Fine-Grained Complexity and Pattern MatchingNick Fischer, Ce Jin, Yinzhan XuSODA 2025 · 2 citations
- Faster two-dimensional pattern matching with k mismatchesJonas Ellert, Pawel Gawrychowski, Adam Górkiewicz, Tatiana StarikovskayaSODA 2025 · 1 citation
- Near-Optimal Property Testers for Pattern MatchingCe Jin, Tomasz KociumakaFOCS 2025 · 1 citation
- Shaving Logs via Large Sieve Inequality: Faster Algorithms for Sparse Convolution and MoreCe Jin, Yinzhan XuSTOC 2024 · 1 citation
Builds on12
- New Bounds for Matrix Multiplication: from Alpha to OmegaVirginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, Renfei ZhouSODA 2024 · 90 citations
- Faster Matrix Multiplication via Asymmetric HashingRan Duan, Hongxun Wu, Renfei ZhouFOCS 2023 · 54 citations
- Top-k-convolution and the quest for near-linear output-sensitive subset sumKarl Bringmann, Vasileios NakosSTOC 2020 · 18 citations
- A Fine-Grained Perspective on Approximating Subset Sum and PartitionKarl Bringmann, Vasileios NakosSODA 2021 · 14 citations
- Elliptic Curve Fast Fourier Transform (ECFFT) Part I: Low-degree Extension in Time O(n log n) over all Finite FieldsEli Ben-Sasson, Dan Carmon, Swastik Kopparty, David LevitSODA 2023 · 12 citations
Related papers
- Approximating text-to-pattern Hamming distancesTimothy M. Chan, Shay Golan, Tomasz Kociumaka, Tsvi Kopelowitz et al.STOC 2020 · 2 citations
- Near-Optimal-Time Quantum Algorithms for Approximate Pattern MatchingTomasz Kociumaka, Jakob Nogler, Philip WellnitzSODA 2025 · 1 citation
- Small-space and streaming pattern matching with editsTomasz Kociumaka, Ely Porat, Tatiana StarikovskayaFOCS 2021 · 13 citations
- Faster Approximate Pattern Matching: A Unified ApproachPanagiotis Charalampopoulos, Tomasz Kociumaka, Philip WellnitzFOCS 2020 · 2 citations
- 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
