Acta Informatica

, Volume 52, Issue 7–8, pp 573–592 | Cite as

Gray code orders for \(q\)-ary words avoiding a given factor

  • A. Bernini
  • S. Bilotta
  • R. Pinzani
  • A. Sabri
  • V. Vajnovszki
Original Article


Based on order relations inspired by the binary reflected Gray code (BRGC) we define Gray codes and give a generating algorithm for \(q\)-ary words avoiding a prescribed factor. These generalize an early 2001 result and a very recent one published by some of the present authors, and can be seen as an alternative to those of Squire published in 1996. Among the involved tools, we make use of generalized BRGC order relations, ultimate periodicity of infinite words, and word matching techniques.


  1. 1.
    Bernini, A., Bilotta, S., Pinzani, R., Vajnovszki, V.: Two Gray codes for \(q\)-ary \(k\)-generalized Fibonacci strings. In: ICTCS13, Palermo-Italy, 9–11 Sept (2013)Google Scholar
  2. 2.
    Bilotta, S., Pergola, E., Pinzani, R.: A construction for a class of binary words avoiding \(1^j0^i\). Pu.M.A 23(2), 81–102 (2012)Google Scholar
  3. 3.
    Bilotta, S., Merlini, D., Pergola, E., Pinzani, R.: Pattern \(1^{j+1}0^j\) avoiding binary words. Fund. Inf. 117, 35–55 (2012)zbMATHMathSciNetGoogle Scholar
  4. 4.
    Er, M.C.: On generating the \(N\)-ary reflected Gray code. IEEE Trans. Comput. 33(8), 739–741 (1984)Google Scholar
  5. 5.
    Gray, F.: Pulse code communication. US Patent 2632058 (1953)Google Scholar
  6. 6.
    Guibas, L.J., Odlyzko, A.M.: Periods in strings. J. Comb. Theory Ser. A 30(1), 19–42 (1981)zbMATHMathSciNetCrossRefGoogle Scholar
  7. 7.
    Heubach, S., Mansour, T.: Combinatorics of Compositions and Words. Chapman and Hall/CRC, Taylor & Francis Group, Boca Raton, London, New York (2009)Google Scholar
  8. 8.
    Joichi, J., White, D.E., Williamson, S.G.: Combinatorial Gray codes. SIAM J. Comput. 9, 130–141 (1980)Google Scholar
  9. 9.
    Knuth, D.E., Morris, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6, 323–350 (1977)zbMATHMathSciNetCrossRefGoogle Scholar
  10. 10.
    Li, Y., Sawada, J.: Gray codes for reflectable languages. Inf. Process. Lett. 109(5), 296–300 (2009)zbMATHMathSciNetCrossRefGoogle Scholar
  11. 11.
    Lothaire, M.: Applied Combinatorics on Words. Cambridge University Press, New York (2005)zbMATHCrossRefGoogle Scholar
  12. 12.
    Sabri, A., Vajnovszki, V.: Two reflected Gray code based orders on some restricted growth sequences. Comput. J. (to appear)Google Scholar
  13. 13.
    Squire, M.: Gray codes for \(A\)-free strings. Electr. J. Comb. 3(paper R17) (1996)Google Scholar
  14. 14.
    Ruskey, F.: Combinatorial Generation (book in preparation)Google Scholar
  15. 15.
    Vajnovszki, V.: A loopless generation of bitstrings without \(p\) consecutive ones. In: Calude, C.S., Dinneen, M.J., Sburlan, S. (eds.) Combinatorics, Computability and Logic. Discrete Mathematics and Theoretical Computer Science, pp. 227–240. Springer, London (2001)Google Scholar
  16. 16.
    Vajnovszki, V., Vernay, R.: Restricted compositions and permutations: from old to new Gray codes. Inf. Process. Lett. 111(13), 650–655 (2011)Google Scholar
  17. 17.
  18. 18.
    Walsh, T.: Generating Gray codes in \(O(1)\) worst-case time per word. In: 4th Discrete Mathematics and Theoretical Computer Science Conference, Dijon-France, 7–12 July 2003 (LNCS), vol. 2731, pp. 73–88 (2003)Google Scholar
  19. 19.
    Walsh, T.: Loop-free sequencing of bounded integer compositions. J. Comb. Math. Comb. Comput. 33, 323–345 (2000)zbMATHGoogle Scholar
  20. 20.
    Williamson, S.G.: Combinatorics for Computer Science. Computer Science Press, Rockville (1985)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • A. Bernini
    • 1
  • S. Bilotta
    • 1
  • R. Pinzani
    • 1
  • A. Sabri
    • 2
  • V. Vajnovszki
    • 2
  1. 1.Dipartimento di Matematica e Informatica “Ulisse Dini”Università degli Studi di FirenzeFlorenceItaly
  2. 2.LE2IUniversité de BourgogneDijon CedexFrance

Personalised recommendations