Faster Algorithms for Text-to-Pattern Hamming Distances
Abstract
We study the classic Text-to-Pattern Hamming Distances problem: given a pattern of length and a text of length , both over a polynomial-size alphabet, compute the Hamming distance between and for every shift , 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 -bounded setting, with running time , removing all the extra logarithmic factors from earlier algorithms [Gawrychowski and Uzna\'{n}ski, 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, beating the previous running time [Kopelowitz and Porat, FOCS 2015; Kopelowitz and Porat, SOSA 2018]. Our approximation algorithm exploits a connection with SUM, 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 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 SUM.
Cite
@article{arxiv.2310.13174,
title = {Faster Algorithms for Text-to-Pattern Hamming Distances},
author = {Timothy M. Chan and Ce Jin and Virginia Vassilevska Williams and Yinzhan Xu},
journal= {arXiv preprint arXiv:2310.13174},
year = {2024}
}
Comments
Appeared in FOCS 2023. Abstract shortened to fit arXiv requirements. v3: Fixed a mistake in the proof of Lemma 5.3 (and changed the auxiliary Lemma 5.2). v2: added reference and discussion related to Lemma 2.2 and Appendix B