Ranking and Loopless Generation of k-ary Dyck Words in Cool-lex Order

  • Stephane Durocher
  • Pak Ching Li
  • Debajyoti Mondal
  • Aaron Williams
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7056)


A binary string B of length n = k t is a k-ary Dyck word if it contains t copies of 1, and the number of 0s in every prefix of B is at most k−1 times the number of 1s. We provide two loopless algorithms for generating k-ary Dyck words in cool-lex order: (1) The first requires two index variables and assumes k is a constant; (2) The second requires t index variables and works for any k. We also efficiently rank k-ary Dyck words in cool-lex order. Our results generalize the “coolCat” algorithm by Ruskey and Williams (Generating balanced parentheses and binary trees by prefix shifts in CATS 2008) and provide the first loopless and ranking applications of the general cool-lex Gray code by Ruskey, Sawada, and Williams (Binary bubble languages and cool-lex order under review).


Binary String Gray Code Combinatorial Object Successor Rule Successive Object 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Canfield, E., Williamson, S.: A loop-free algorithm for generating the linear extensions of a poset. Order 12, 57–75 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Heubach, S., Li, N.Y., Mansour, T.: A garden of k-Catalan structures (2008),
  3. 3.
    Knuth, D.E.: The Art of Computer Programming: Generating all Trees and History of Combinatorial Generation, vol. 4. Addison-Wesley (2006)Google Scholar
  4. 4.
    Pruesse, G., Ruskey, F.: Generating the linear extensions of certain posets by transpositions. SIAM Journal on Discrete Mathematics 4(3), 413–422 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Ruskey, F.: Generating t-ary trees lexicographically. SIAM Journal on Computing 7(4), 424–439 (1978)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Ruskey, F., Sawada, J., Williams, A.: Binary bubble languages and cool-lex order, 13 pages (2010) (under review)Google Scholar
  7. 7.
    Ruskey, F., Williams, A.: Generating balanced parentheses and binary trees by prefix shifts. In: Proceedings of the 14th Computing: The Australasian Theory Symposium (CATS 2008), NSW, Australia, January 22-25, vol. 77, pp. 107–115 (2008)Google Scholar
  8. 8.
    Trojanowski, A.E.: Ranking and listing algorithms for k-ary trees. SIAM Journal on Computing 7(4), 492–509 (1978)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Vajnovszki, V., Walsh, T.: A loop-free two-close Gray-code algorithm for listing k-ary Dyck words. Journal of Discrete Algorithms 4(4), 633–648 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Zaks, S.: Generation and ranking of k-ary trees. Information Processing Letters 14(1), 44–48 (1982)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Stephane Durocher
    • 1
  • Pak Ching Li
    • 1
  • Debajyoti Mondal
    • 1
  • Aaron Williams
    • 2
  1. 1.Department of Computer ScienceUniversity of ManitobaCanada
  2. 2.Department of Mathematics and StatisticsCarleton UniversityCanada

Personalised recommendations