English

A Fast Heuristic for Exact String Matching

Data Structures and Algorithms 2015-12-14 v1

Abstract

Given a pattern string PP of length nn consisting of δ\delta distinct characters and a query string TT of length mm, where the characters of PP and TT are drawn from an alphabet Σ\Sigma of size Δ\Delta, the {\em exact string matching} problem consists of finding all occurrences of PP in TT. For this problem, we present a randomized heuristic that in O(nδ)O(n\delta) time preprocesses PP to identify sparse(P)sparse(P), a rarely occurring substring of PP, and then use it to find all occurrences of PP in TT efficiently. This heuristic has an expected search time of O(mmin(sparse(P),Δ))O( \frac{m}{min(|sparse(P)|, \Delta)}), where sparse(P)|sparse(P)| is at least δ\delta. We also show that for a pattern string PP whose characters are chosen uniformly at random from an alphabet of size Δ\Delta, E[sparse(P)]E[|sparse(P)|] is Ω(Δlog(2Δ2Δδ))\Omega(\Delta log (\frac{2\Delta}{2\Delta-\delta})).

Keywords

Cite

@article{arxiv.1512.03512,
  title  = {A Fast Heuristic for Exact String Matching},
  author = {Srikrishnan Divakaran},
  journal= {arXiv preprint arXiv:1512.03512},
  year   = {2015}
}

Comments

arXiv admin note: substantial text overlap with arXiv:1509.09228

R2 v1 2026-06-22T12:06:58.870Z