Skip to main content
Log in

Optimal parallel detection of squares in strings

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. A. Apostolico, On Context-Constrained Squares and Repetitions in a String,RAIRO Inform. Théor. 18 (1984), 147–159.

    MATH  MathSciNet  Google 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.

    Article  MATH  MathSciNet  Google Scholar 

  3. A. Apostolico and Z. Galil (eds.),Combinatorial Algorithms on Words, Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985.

    MATH  Google 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.

    Article  MATH  MathSciNet  Google Scholar 

  5. A. Apostolico and F. P. Preparata, Optimal Off-Line Detection of Repetitions in a String,Theoret. Comput. Sci. 22 (1983), 297–315.

    Article  MATH  MathSciNet  Google Scholar 

  6. A. Apostolico and F. P. Preparata. Structural Properties of the String Stratistics ProblemJ. Comput. System. Sci. 31(3) (1985), 394–411.

    Article  MATH  MathSciNet  Google 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.

  8. K. T. Chen, R. H. Fox, and R. C. Lyndon, Free Differential Calculus, IV,Ann. of Math. 68 (1958), 81–95.

    Article  MathSciNet  Google Scholar 

  9. M. Crochemore, An Optimal Algorithm for Computing the Repetitions in a Word,Inform. Process. Lett. 12(5) (1981), 244–250.

    Article  MATH  MathSciNet  Google Scholar 

  10. M. Crochemore, Recherche Linearire d'un Carré dans un MotC. R. Acad. Sci. Paris Sér. I 296 (1983), 781–784.

    MATH  MathSciNet  Google 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.

    Article  MATH  MathSciNet  Google Scholar 

  12. J. P. Duval, Factorizing Words over an Ordered Alphabet,J. Algorithms 4 (1983), 363–381.

    Article  MATH  MathSciNet  Google 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.

  14. M. Lothaire,Combinatorics on Words, Addison-Wesley, Reading, Mass., 1982.

    Google Scholar 

  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.

    Article  MATH  MathSciNet  Google Scholar 

  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.

    Article  MathSciNet  Google Scholar 

  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. 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. 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.

    MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Additional information

Communicated by C. K. Wong.

This research was supported, through the Leonardo Fibonacci Institute, by the Istituto Trentino di Cultura, Trento, Italy. Additional support was provided by the French and Italian Ministries of Education, by the National Research Council of Italy, by the British Research Council Grant SERC-E76797, by NSF Grant CCR-89-00305, by NIH Library of Medicine Grant ROI LM05118, by AFOSR Grant 90-0107, and by NATO Grant CRG900293.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Apostolico, A. Optimal parallel detection of squares in strings. Algorithmica 8, 285–319 (1992). https://doi.org/10.1007/BF01758848

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01758848

Key words

Navigation