Abstract
A square is an immediately repeated nonempty string, e.g., aa, abab, abcabc. This paper presents a new O(n log n) algorithm to determine whether a string of length n has a substring which is a square. The algorithm is not as general as some previous algorithms for finding all squares [1,7,8,13], but it does have a simplicity which the others lack. Also, for a fixed alphabet of size k, the algorithm can be improved by a factor of log k (n), yielding an O(n) algorithm for determining whether a string contains a square.
Research supported by the University of Colorado Council on Research and Creative Work.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
A. Apostolico and F.P. Preparata, Optimal off-line detection of repetitions in a string, TCS 22 (1983) 297–315.
S.E. Arshon, Dokazatel’stov suscestvovanija n-znacnyh beskonecnyh asim-metricnyh posledovatel’nostei, Mat. Sb. 44 (1937), 769–779.
D.R. Bean, A. Ehrenfeucht and G.F. McNulty, Avoidable patterns in strings of symbols, Pacific J. Math., 85 (1979), 261–294.
J. Berstel, Sur les mots sans carre definis par un morphisme, in Automata, Languages and Programming (A. Maurer, Ed.), LNCS 71, Springer-Verlag, Berlin, 1979, 16–25.
J. Berstel, Mots sans carre et morphismes iters, Discrete Math. 29 (1979), 235–244.
C.H. Braunholtz, Solution to problem 5030, Am. Math. Mo. 70 (1963), 675–676.
M. Crochemore, Determination optimale des repetitions dans un mot, Technical Report 80–53, Laboratoire Informatique Theorique et Programmation, University of Paris (1981).
M. Crochemore, An optimal algorithm for computing repetitions in a word, IPL 12 (1981), 244–250.
A.A. Evdokimov, Strongly asymmetric sequences generated by a finite number of symbols, Soviet Math. Dokl., 9 (1968), 536–539.
D. Hawkins and W.E. Mientka, On sequences which contain no repetitions, Math. Student 24 (1956), 185–187. MR 19 (1958) #241.
G.A. Hedlund, Remarks on the work of Axel Thue on sequences, Nord. Mat. Tidskr. 16 (1967), 148–150. MR 37 (1959), #4454.
M.G. Main and R.J. Lorentz, An 0(nlogn) algorithm for recognizing repetition, Washington State University Technical Report CS-79–056, Pullman, WA 99164 (1979).
M.G. Main and R.J. Lorentz, An 0(n logn) algorithm for finding all repetitions in a string, J. of Algorithms, to appear (1984).
M. Morse, A solution of the problem of infinite play in chess, Bull. Amer. Math. Soc., 44 (1938), 632.
M. Morse and G.A. Hedlund, Unending chess, symbolic dynamics and a problem in semigroups, Duke Math. J. 11 (1944), 1–7. MR 5 (1944) #202.
P.A.B. Pleasants, Nonrepetitive sequences, Proc. Cambridge Phil. Soc. 68 (1970), 267–274.
A. Thue, Uber unendliche Zeichenreihen. Norske Wdenskabers Selskabs Skrifter Mat.-Nat. Kl. (Kristiania) (1906), Nr. 7, 1–22.
A. Thue, Uber die gegenseitige Lage gleicher Teile gewisser Zeichenreihen, Norske Vlcienskabers Selskabs Skrifter Mat.-Nat. Kl. (Kristiania) (1912), Nr. 1, 1–67.
T. Zech, Wiederholungsfreie Folgen, Z. Angew. Math. Mech. 38 (1958), 206–209.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1985 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Main, M.G., Lorentz, R.J. (1985). Linear Time Recognition of Squarefree Strings. In: Apostolico, A., Galil, Z. (eds) Combinatorial Algorithms on Words. NATO ASI Series, vol 12. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-82456-2_18
Download citation
DOI: https://doi.org/10.1007/978-3-642-82456-2_18
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-82458-6
Online ISBN: 978-3-642-82456-2
eBook Packages: Springer Book Archive