# Optimal parallel detection of squares in strings

- 75 Downloads
- 10 Citations

## Abstract

A string*w* is*primitive* if it is not a power of another string (i.e., writing*w* =*v* ^{ k } implies*k* = 1. Conversely,*w* is a*square* if*w* =*vv*, with*v* a primitive string. A string*x* is*square-free* if it has no nonempty substring of the form*ww*. It is shown that the square-freedom of a string of*n* symbols over an arbitrary alphabet can be tested by a CRCW PRAM with*n* processors in*O*(log*n*) time and linear auxiliary space. If the cardinality of the input alphabet is bounded by a constant independent of the input size, then the number of processors can be reduced to*n*/log*n* without affecting the time complexity of this strategy. The fastest sequential algorithms solve this problem*O*(*n* log*n*) or*O*(*n*) time, depending on whether the cardinality of the input alphabet is unbounded or bounded, and either performance is known to be optimal within its class. More elaborate constructions lead to a CRCW PRAM algorithm for detecting, within the same*n*-processors bounds, all positioned squares in*x* in time*O*(log*n*) and using linear auxiliary space. The fastest sequential algorithms solve this problem in*O*(*n* log*n*) time, and such a performance is known to be optimal.

## Key words

Parallel computation Combinatorial algorithms on words String matching Avoidable regularities Squares and repetitions in a string## Preview

Unable to display preview. Download preview PDF.

## References

- [1]A. Apostolico, On Context-Constrained Squares and Repetitions in a String,
*RAIRO Inform. Théor.*18 (1984), 147–159.MATHMathSciNetGoogle Scholar - [2]A. Apostolico, M. J. Atallah, L. L. Larmore, and H. S. McFaddin, Efficient Parallel Algorithms for String Editing and Related Problems,
*SIAM J. Comput.***19**(5) (1990), 968–988. Also,*Proceedings of the 26th Allerton Conference on Communications, Control and Computing*, Monticello, Ill., Sept. 1988, pp. 253–263.MATHCrossRefMathSciNetGoogle Scholar - [3]A. Apostolico and Z. Galil (eds.),
*Combinatorial Algorithms on Words*, Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985.MATHGoogle Scholar - [4]A. Apostolico, C. Iliopoulos, G. Landau, B. Schieber, and U. Vishkin, Parallel Construction of a Suffix Tree, with Applications,
*Algorithmica***3**(1988), 347–365.MATHCrossRefMathSciNetGoogle Scholar - [5]A. Apostolico and F. P. Preparata, Optimal Off-Line Detection of Repetitions in a String,
*Theoret. Comput. Sci.***22**(1983), 297–315.MATHCrossRefMathSciNetGoogle Scholar - [6]A. Apostolico and F. P. Preparata. Structural Properties of the String Stratistics Problem
*J. Comput. System. Sci.***31**(3) (1985), 394–411.MATHCrossRefMathSciNetGoogle Scholar - [7]O. Berkman, D. Breslauer, Z, Galil, B. Schieber, and U. Vishkin, Hightly Parallelizable Problems,
*Proceedings of the 21st ACM Symposium on Theory of Computing*, Seattle, Wash., May 1989, pp. 309–319.Google Scholar - [8]K. T. Chen, R. H. Fox, and R. C. Lyndon, Free Differential Calculus, IV,
*Ann. of Math.***68**(1958), 81–95.CrossRefMathSciNetGoogle Scholar - [9]M. Crochemore, An Optimal Algorithm for Computing the Repetitions in a Word,
*Inform. Process. Lett.***12**(5) (1981), 244–250.MATHCrossRefMathSciNetGoogle Scholar - [10]M. Crochemore, Recherche Linearire d'un Carré dans un Mot
*C. R. Acad. Sci. Paris Sér. I***296**(1983), 781–784.MATHMathSciNetGoogle Scholar - [11]M. Crochemore and W. Rytter, Usefulness of the Karp-Miller-Rosenberg Strategy in the Design of Parallel Algorithms,
*Theoret. Comput. Sci.***88**(1991), 59–82.MATHCrossRefMathSciNetGoogle Scholar - [12]J. P. Duval, Factorizing Words over an Ordered Alphabet,
*J. Algorithms***4**(1983), 363–381.MATHCrossRefMathSciNetGoogle Scholar - [13]F. E. Fich, R. L. Ragde, and A. Wigderson, Relations between Concurrent-Write Models of Parallel Computation,
*Proceedings of the 3rd A CM Symposium on Principles of Distributed Computing*, Vancouver, B.C., Aug. 27–29, 1984, pp. 179–184.Google Scholar - [14]M. Lothaire,
*Combinatorics on Words*, Addison-Wesley, Reading, Mass., 1982.Google Scholar - [15]R. C. Lyndon and M. P. Shutzenberger, The Equation
*a*^{M}*= b*^{N}*c*^{P}in a Free Group,*Michigan Math. J.***9**(1962), 289–298.MATHCrossRefMathSciNetGoogle Scholar - [16]M. G. Main and R. J. Lorentz, An
*O(n*log*n)*Algorithm for Finding all Repetitions in a String,*J. Algorithms***5**(1985), 422–432.CrossRefMathSciNetGoogle Scholar - [17]M. G. Main and R. J. Lorentz, Linear-Time Recognition of Square-Free Strings, in
*Combinatorial Algorithms on Words*(A. Apostolico and Z. Galil, eds.), Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985, pp. 271–278.Google Scholar - [18]M. Rabin, Discovering Repetitions in Strings, in
*Combinatorial Algorithms on Words*(A. Apostolico and Z. Galil, eds), Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985, pp. 279–288.Google Scholar - [19]A. Thue, Über unendliche Zeichenreihen,
*Norske Vid. Selsk. I Mat. Natur. Kl. Skr.*, Christiania no. 7 (1906), 1–22.Google Scholar - [20]A. Thue, “Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen”,
*Norske Vid. Selsk. I Mat.-Natur. Kl. Skr.*, Christiania no. 1 (1912), 1–67.Google Scholar - [21]C. K. Wong and A. K. Chandra, Bounds for the String Editing Problem,
*J. Assoc. Comput. Mach.***23**(1) (1976), 13–16.MATHMathSciNetGoogle Scholar