 
Summary: An Alphabet Independent Approach to Two Dimensional Matching
Amihood Amiry Gary Bensonz Martin Farachx
Georgia Tech Univ. of Maryland DIMACS
Abstract
There are many solutions to the string matching problem which are strictly linear in the
input size and independent of alphabet size. Furthermore, the model of computation for these
algorithms is very weak: they allow only simple arithmetic and comparisons of equality be
tween characters of the input. In contrast, algorithm for two dimensionalmatching have needed
stronger models of computation, most notably assuming a totally ordered alphabet. The fastest
algorithmsfor two dimensionalmatchinghave therefore had a logarithmicdependence on the al
phabet size. In the worst case, this gives an algorithmthat runs in O(n2 logm) with O(m2 logm)
preprocessing.
We show an algorithm for two dimensional matching with an O(n2) text scanning phase.
Furthermore, the text scan requires no special assumptionsabout the alphabet, i.e.itruns on the
same model as the standard linear time string matching algorithm. The pattern preprocessing
requires an ordered alphabet and runs with the same alphabet dependency as the previously
known algorithms.
Key Words: multidimensional matching, period, string
AMS(MOS) subject classi cations: 68Q05, 68Q20, 68Q25
Abreviated title: Two Dimensional Matching
