Abstract
We present the first known (alphabet independent) algorithm for two-dimensional pattern matching which works in linear time and small space simultaneously. The searching phase of our algorithm works in O(1) space and is followed by pattern preprocessing performed in O(logm) space. Up to now there was not known even any efficient sublinear space algorithm for this problem. The main tools in our algorithm are several 2-dimensional variations of deterministic sampling, originally used in parallel pattern matching: small, frame and wide samples. Another novel idea used in our algorithm is the technique of zooming sequences: the sequences of nonperiodic decreasing parts of the pattern (samples) of similar regular shapes. Their regularity allows to encode the zooming sequences in small memory (logarithmic number of bits) while nonperiodicity allows to make shifts (kill positions as candidates for a match) in a way amortizing the work. The preprocessing phase is recursive, its structure is similar to the linear time algorithm for the selection problem. The stack of the recursion consists of logarithmic number of integers. Our algorithm is rather complicated, but all known alphabet-independent linear time algorithms (even with unrestricted space) for 2d-matching are quite complicated, too.
Supported by the Grant KBN 2-1190-91-01
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
A. Amir and G. Benson, Two dimensional periodicity and its applications, Proc. 3rd ACM-SIAM SODA'92, p. 440–452.
A. Amir, G. Benson and M. Farach, Alphabet independent two dimensional matching, Proc. 24th ACM STOC'92, p. 59–68.
A. Amir, G. Benson and M. Farach, Optimal parallel two dimensional pattern matching, Proc. 5th ACM SPAA'93, p. 79–85.
T. J. Baker, A technique for extending rapid exact-match string matching to arrays of more than one dimension, SIAM J. Comp. 7 (1978), p. 533–541.
R. S. Bird, Two dimensional pattern matching, Inf. Proc. Letters 6, (1977) p. 168–170.
R. Cole, M. Crochemore, Z. Galil, L. Gasieniec, R. Hariharan, S. Muthukrishnan, K. Park and W. Rytter, Optimally fast parallel algorithms for preprocessing and pattern matching in one and two dimensions, Proc. 34th IEEE FOCS'93, p. 248–258.
M. Crochemore, String matching for ordered alphabets, TCS 92 (1992), p. 225–251.
M. Crochemore and D. Perrin, Two-way string matching, JACM 38:3 (1991), p. 651–675.
M. Crochemore, L. Gasieniec and W. Rytter, Two-dimensional pattern matching by sampling, IPL 46 (1993), p. 159–162.
M. Crochemore and W. Rytter, A version of Galil-Park two-dimensional matching, Report IGM 94-05, Universite Marne la Valle (1994).
Z. Galil and K. Park, Truly alphabet independent two dimensional matching, Proc. 33th IEEE FOCS'92, (1992) p. 247–256.
Z. Galil and J. Seiferas, Time-space optimal string matching, J. Comp. Syst. Sc. 26 (1983), p. 280–294.
L. Gasieniec, W. Plandowski and W. Rytter, The zooming method: a recursive approach to time-space efficient string-matching, TCS, to appear.
U. Vishkin, Deterministic sampling — a new technique for fast pattern matching, SIAM J. Comput. 20 (1991), p. 22–40.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1995 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Crochemore, M., Gasieniec, L., Rytter, W., Plandowski, W. (1995). Two-dimensional pattern matching in linear time and small space. In: Mayr, E.W., Puech, C. (eds) STACS 95. STACS 1995. Lecture Notes in Computer Science, vol 900. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-59042-0_72
Download citation
DOI: https://doi.org/10.1007/3-540-59042-0_72
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-59042-2
Online ISBN: 978-3-540-49175-0
eBook Packages: Springer Book Archive