Linear-Time Version of Holub’s Algorithm for Morphic Imprimitivity Testing

  • Tomasz Kociumaka
  • Jakub Radoszewski
  • Wojciech Rytter
  • Tomasz Waleń
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7810)


Stepan Holub (Discr. Math., 2009) gave the first polynomial algorithm deciding whether a given word is a nontrivial fixed point of a morphism. His algorithm works in quadratic time for large alphabets. We improve the algorithm to work in linear time. Our improvement starts with a careful choice of a subset of rules used in Holub’s algorithm that is necessary to grant correctness of the algorithm.Afterwards we show how to choose the order of applying the rules that allows to avoid unnecessary operations on sets. We obtain linear time using efficient data structures for implementation of the rules. Holub’s algorithm maintains connected components of a graph corresponding to specially marked positions in a word. This graph is of quadratic size for large alphabet. In our algorithm only a linear number of edges of this conceptual graph is processed.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Crochemore, M., Hancart, C., Lecroq, T.: Algorithms on Strings. Cambridge University Press (2007)Google Scholar
  2. 2.
    Ehrenfeucht, A., Rozenberg, G.: Finding a homomorphism between two words is NP-complete. Inf. Process. Lett. 9(2), 86–88 (1979)MathSciNetzbMATHCrossRefGoogle Scholar
  3. 3.
    Gabow, H.N., Tarjan, R.E.: A linear-time algorithm for a special case of disjoint set union. In: Proceedings of the 15th Annual ACM Symposium on Theory of Computing (STOC), pp. 246–251 (1983)Google Scholar
  4. 4.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)MathSciNetzbMATHCrossRefGoogle Scholar
  5. 5.
    Head, T.: Fixed languages and the adult languages of OL schemes. International Journal of Computer Mathematics 10(2), 103–107 (1981)MathSciNetzbMATHCrossRefGoogle Scholar
  6. 6.
    Head, T., Lando, B.: Fixed and stationary ω-words and ω-languages. In: Rozenberg, G., Salomaa, A. (eds.) The Book of L, pp. 147–156. Springer (1986)Google Scholar
  7. 7.
    Holub, S.: Algorithm for fixed points of morphisms — visualization,
  8. 8.
    Holub, S.: Polynomial-time algorithm for fixed points of nontrivial morphisms. Discrete Mathematics 309(16), 5069–5076 (2009)MathSciNetzbMATHCrossRefGoogle Scholar
  9. 9.
    Ilie, L., Tinta, L.: Practical Algorithms for the Longest Common Extension Problem. In: Karlgren, J., Tarhio, J., Hyyrö, H. (eds.) SPIRE 2009. LNCS, vol. 5721, pp. 302–309. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  10. 10.
    Matocha, V., Holub, S.: Complexity of testing morphic primitivity. CoRR abs/1207.5690v1 (2012)Google Scholar
  11. 11.
    Reidenbach, D., Schneider, J.C.: Morphically primitive words. Theor. Comput. Sci. 410(21-23), 2148–2161 (2009), MathSciNetzbMATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Tomasz Kociumaka
    • 1
  • Jakub Radoszewski
    • 1
  • Wojciech Rytter
    • 1
    • 2
  • Tomasz Waleń
    • 3
    • 1
  1. 1.Faculty of Mathematics, Informatics and MechanicsUniversity of WarsawWarsawPoland
  2. 2.Faculty of Mathematics and Computer ScienceNicolaus Copernicus UniversityToruńPoland
  3. 3.Laboratory of Bioinformatics and Protein EngineeringInternational Institute of Molecular and Cell Biology in Warsaw, PolandWarsawPoland

Personalised recommendations