For any given k, the sequence of k-ary Catalan numbers, C t,k = 1 kt+1 kt t , enumerates a number of combinatorial objects, including k-ary Dyck words of length n = kt and k-ary trees with t internal nodes. We show that these objects can be efficiently ordered using the same variation of lexicographic order known as cool-lex order. In particular, we provide loopless algorithms that generate each successive object in O(1) time. The algorithms are also efficient in terms of memory, with the k-ary Dyck word algorithm using O(1) additional index variables, and the k-ary tree algorithm using O(t) additional pointers and index variables. We also show how to efficiently rank and unrank k-ary Dyck words in cool-lex order using O(kt) arithmetic operations, subject to an initial precomputation. Our results are based on the cool-lex successor rule for sets of binary strings that are bubble languages. However, we must complement and reverse 1/k-ary Dyck words to obtain the stated efficiency.An important problem in discrete mathematics and theoretical computer science is the creation of efficient orders for combinatorial objects. The research area that studies this problem is combinatorial generation, and it is overviewed by Knuth in the most recent volume of The Art of Computer Programming [12]. In this article we will show that cool-lex order is an efficient order for k-ary Catalan objects. To frame our results, this section provides background on combinatorial generation, k-ary Catalan objects, and cool-lex order.
Combinatorial generationTo understand combinatorial generation, we explain each of the terms in "efficient orders for combinatorial objects" and then provide several examples. By 'combinatorial objects' we are referring to a set of objects of a particular size and type, such as binary strings of length n, permutations of [n] = {1, 2, . . . ,n} in one-line notation, trees on n vertices, and so on.The size of the object is usually denoted by n, and the number of objects by m. An 'order' is a list in which each object in the set appears exactly once. Finally, we associate three interrelated operations with each order, for which we evaluate 'efficiency' according to the worst-case time complexity: