Approximating Text-to-Pattern Hamming Distances
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 between the pattern and the text at every location. Several -approximation algorithms have been proposed in the literature, with running time of the form , all using fast Fourier transform (FFT). We describe a simple -approximation algorithm that is faster and does not need FFT. Combining our approach with additional ideas leads to numerous new results: - We obtain the first linear-time approximation algorithm; the running time is . - We obtain a faster exact algorithm computing all Hamming distances up to a given threshold k; its running time improves previous results by logarithmic factors and is linear if . - We obtain approximation algorithms with better -dependence using rectangular matrix multiplication. The time-bound is when the pattern is sufficiently long: . Previous algorithms require time. - 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 time, where occ is the output size. The algorithm leads to a property tester, returning true if an exact match exists and false if the Hamming distance is more than at every location, running in time. - We obtain a streaming algorithm to report all locations with Hamming distance approximately less than k, using space. Previously, streaming algorithms were known for the exact problem with \~O(k) space or for the approximate problem with space.
Cite
@article{arxiv.2001.00211,
title = {Approximating Text-to-Pattern Hamming Distances},
author = {Timothy M. Chan and Shay Golan and Tomasz Kociumaka and Tsvi Kopelowitz and Ely Porat},
journal= {arXiv preprint arXiv:2001.00211},
year = {2020}
}