, Volume 8, Issue 1–6, pp 285–319 | Cite as

Optimal parallel detection of squares in strings

  • Alberto Apostolico


A stringw isprimitive if it is not a power of another string (i.e., writingw =v k impliesk = 1. Conversely,w is asquare ifw =vv, withv a primitive string. A stringx issquare-free if it has no nonempty substring of the formww. It is shown that the square-freedom of a string ofn symbols over an arbitrary alphabet can be tested by a CRCW PRAM withn processors inO(logn) 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 ton/logn without affecting the time complexity of this strategy. The fastest sequential algorithms solve this problemO(n logn) orO(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 samen-processors bounds, all positioned squares inx in timeO(logn) and using linear auxiliary space. The fastest sequential algorithms solve this problem inO(n logn) 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 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    A. Apostolico, On Context-Constrained Squares and Repetitions in a String,RAIRO Inform. Théor. 18 (1984), 147–159.MATHMathSciNetGoogle Scholar
  2. [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. [3]
    A. Apostolico and Z. Galil (eds.),Combinatorial Algorithms on Words, Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985.MATHGoogle Scholar
  4. [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. [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. [6]
    A. Apostolico and F. P. Preparata. Structural Properties of the String Stratistics ProblemJ. Comput. System. Sci. 31(3) (1985), 394–411.MATHCrossRefMathSciNetGoogle Scholar
  7. [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. [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. [9]
    M. Crochemore, An Optimal Algorithm for Computing the Repetitions in a Word,Inform. Process. Lett. 12(5) (1981), 244–250.MATHCrossRefMathSciNetGoogle Scholar
  10. [10]
    M. Crochemore, Recherche Linearire d'un Carré dans un MotC. R. Acad. Sci. Paris Sér. I 296 (1983), 781–784.MATHMathSciNetGoogle Scholar
  11. [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. [12]
    J. P. Duval, Factorizing Words over an Ordered Alphabet,J. Algorithms 4 (1983), 363–381.MATHCrossRefMathSciNetGoogle Scholar
  13. [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. [14]
    M. Lothaire,Combinatorics on Words, Addison-Wesley, Reading, Mass., 1982.Google Scholar
  15. [15]
    R. C. Lyndon and M. P. Shutzenberger, The Equationa M = b N c P in a Free Group,Michigan Math. J. 9 (1962), 289–298.MATHCrossRefMathSciNetGoogle Scholar
  16. [16]
    M. G. Main and R. J. Lorentz, AnO(n logn) Algorithm for Finding all Repetitions in a String,J. Algorithms 5 (1985), 422–432.CrossRefMathSciNetGoogle Scholar
  17. [17]
    M. G. Main and R. J. Lorentz, Linear-Time Recognition of Square-Free Strings, inCombinatorial 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. [18]
    M. Rabin, Discovering Repetitions in Strings, inCombinatorial 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. [19]
    A. Thue, Über unendliche Zeichenreihen,Norske Vid. Selsk. I Mat. Natur. Kl. Skr., Christiania no. 7 (1906), 1–22.Google Scholar
  20. [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. [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

Copyright information

© Springer-Verlag New York Inc. 1992

Authors and Affiliations

  • Alberto Apostolico
    • 1
    • 2
  1. 1.Department of Computer SciencePurdue UniversityWest LafayetteUSA
  2. 2.Dipartimento di Matematica Pura e ApplicataUniversità de L'Aquila L'AquilaItaly

Personalised recommendations