Pattern Matching with Mismatches and Wildcards
Abstract
In this work, we address the problem of approximate pattern matching with wildcards. Given a pattern of length containing wildcards, a text of length , and an integer , our objective is to identify all fragments of within Hamming distance from . Our primary contribution is an algorithm with runtime for this problem. Here, represents the number of maximal wildcard fragments in . We derive this algorithm by elaborating in a non-trivial way on the ideas presented by [Charalampopoulos et al., FOCS'20] for pattern matching with mismatches (without wildcards). Our algorithm improves over the state of the art when , , and are small relative to . For instance, if , , and , our algorithm operates in time, surpassing the time requirement of all previously known algorithms. In the case of exact pattern matching with wildcards (), we present a much simpler algorithm with runtime that clearly illustrates our main technical innovation: the utilisation of positions of that do not belong to any fragment of with a density of wildcards much larger than as anchors for the sought (approximate) occurrences. Notably, our algorithm outperforms the best-known -time FFT-based algorithms of [Cole and Hariharan, STOC'02] and [Clifford and Clifford, IPL'04] if . We complement our algorithmic results with a structural characterization of the -mismatch occurrences of . We demonstrate that in a text of length , these occurrences can be partitioned into arithmetic progressions. Additionally, we construct an infinite family of examples with arithmetic progressions of occurrences, leveraging a combinatorial result on progression-free sets [Elkin, SODA'10].
Cite
@article{arxiv.2402.07732,
title = {Pattern Matching with Mismatches and Wildcards},
author = {Gabriel Bathie and Panagiotis Charalampopoulos and Tatiana Starikovskaya},
journal= {arXiv preprint arXiv:2402.07732},
year = {2024}
}
Comments
This version contains a fix in the proof of Theorem 3.10 and other minor changes