Lune

FOCS2023Top-tier venue

Faster Algorithms for Text-to-Pattern Hamming Distances

Timothy M. Chan, Ce Jin, Virginia Vassilevska Williams, Yinzhan Xu

2023Year
3Citations
4Top-tier citations

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 T[i…i+m−1]T[i \ldots i+m-1] for every shift i, under the standard Word-RAM model with Θ(log⁡n)\Theta(\log n)-bit words.•We provide an O(nm)O(n \sqrt{m}) time Las Vegas randomized algorithm for this problem, beating the decades-old O(nmlog⁡m)O(n \sqrt{m \log m}) running time [Abrahamson, SICOMP 1987]. We also obtain a deterministic algorithm, with a slightly higher O(nm(log⁡mlog⁡log⁡m)1/4)O\left(n \sqrt{m}(\log m \log \log m)^{1 / 4}\right) running time. Our randomized algorithm extends to the k-bounded setting, with running time O(n+nkm)O\left(n+\frac{n k}{\sqrt{m}}\right), removing all the extra logarithmic factors from earlier algorithms [Gawrychowski and Uznanski, ICALP 2018; Chan, Golan, Kociumaka, Kopelowitz and Porat, STOC 2020].•For the (1+ε)(1+\varepsilon)-approximate version of Text-to-Pattern Hamming Distances, we give an O~(ε−0.93n)\widetilde{O}\left(\varepsilon^{-0.93} n\right) time Monte Carlo randomized algorithm (where O~\widetilde{O} hides poly-logarithmic factors), beating the previous O~(ε−1n)\widetilde{O}\left(\varepsilon^{-1} n\right) 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.

Questions to start from

Your agent calls

Luneget_paper_fulltext

Ask in Lune

Free to start. No credit card required.

lune papers fulltext 60f0f71a-8b77-4451-bb9e-fb81cbb68315

Cited by top-tier papers4

Ask how each one uses it

Builds on12

Related papers

Dusk over the sea between two cliffs drawn in fine vertical lines