English

Fast Algorithms for Exact String Matching

Data Structures and Algorithms 2015-10-01 v1

Abstract

Given a pattern string PP of length nn and a query string TT of length mm, where the characters of PP and TT are drawn from an alphabet of size Δ\Delta, the {\em exact string matching} problem consists of finding all occurrences of PP in TT. For this problem, we present algorithms that in O(nΔ2)O(n\Delta^2) time pre-process PP to essentially identify sparse(P)sparse(P), a rarely occurring substring of PP, and then use it to find occurrences of PP in TT efficiently. Our algorithms require a worst case search time of O(m)O(m), and expected search time of O(m/min(sparse(P),Δ))O(m/min(|sparse(P)|, \Delta)), where sparse(P)|sparse(P)| is at least δ\delta (i.e. the number of distinct characters in PP), and for most pattern strings it is observed to be Ω(n1/2)\Omega(n^{1/2}).

Keywords

Cite

@article{arxiv.1509.09228,
  title  = {Fast Algorithms for Exact String Matching},
  author = {Srikrishnan Divakaran},
  journal= {arXiv preprint arXiv:1509.09228},
  year   = {2015}
}
R2 v1 2026-06-22T11:09:20.757Z