Abstract
We address several technical problems related to the time-space optimal string-matching algorithm of Galil and Seiferas (called the GS algorithm). This algorithm contains a parameterk on which the complexity depends and that originally satisfiesk ≥ 4. We show thatk=3 is the least integer for which the GS algorithm works. This value of the parameterk also minimizes the time of the search phase of the string-searching algorithm. With the parameterk=2 we consider a simpler version of the algorithm working in linear time and logarithmic space. This algorithm is based on the following fact: any word of lengthn starts by less than logΦ n squares of primitive prefixes. Fibonacci words have a logarithmic number of square prefixes. Hence, the combinatorics of prefix squares and cubes is essential for string-matching with small memory.
We give a time-space optimal sequential computation of the period of a word based on the GS algorithm. The latter corrects the algorithm given in [GS2] for the computation of periods. We present an optimal parallel algorithm for pattern preprocessing. This paper also provides a cleaner version and a simpler analysis of the GS algorithm.
Similar content being viewed by others
References
A. V. Aho, Algorithms for finding patterns in strings, in: J. van Leeuwen, ed.Handbook of Theoretical Computer Science, vol. A, Elsevier, Amsterdam, 1990, pp. 255–300.
M. Crochemore, String-matching on ordered alphabets,Theoret. Comput. Sci. 92 (1992), 33–47.
M. Crochemore and D. Perrin, Two-way string-matching,J. Assoc. Comput. Mach. 38(3) (1991), 651–675.
Z. Galil and J. Seiferas, Saving space in fast string matching,SIAM J. Comput. 9 (1980), 417–438.
Z. Galil and J. Seiferas, Time-space optimal string matching,J. Comput. System Sci. 26 (1983), 280–294.
A. Gibbons and W. Rytter,Efficient Parallel Algorithms, Cambridge University Press, Cambridge, 1988.
D. E. Knuth, J. H. Morris, Jr., and V. R. Pratt, Fast pattern matching in strings,SIAM J. Comput. 6 (1977), 323–350.
M. Lothaire,Combinatorics on Words, Addison-Wesley, Reading, MA, 1983.
I. Simon, Personal communication, 1989.
U. Vishkin, Optimal parallel pattern matching in strings,Inform. and Control 67 (1985), 91–113.
Author information
Authors and Affiliations
Additional information
Communicated by C. K. Wong.
Work by this author was partially supported by PRC “Mathématiques-Informatique,” by GDR “Informatique et Genome,” and by NATO Grant CRG 900293.
Work by this author was supported by Grant KBN 2-11-90-91-01.
Rights and permissions
About this article
Cite this article
Crochemore, M., Rytter, W. Squares, cubes, and time-space efficient string searching. Algorithmica 13, 405–425 (1995). https://doi.org/10.1007/BF01190846
Received:
Revised:
Issue Date:
DOI: https://doi.org/10.1007/BF01190846