Amortized Efficiency of Ranking and Unranking Left-Child Sequences in Lexicographic Order

A new type of sequences called left-child sequences (LC-sequences for short) was recently introduced by Wu et al. [19] for representing binary trees. In particular, they pointed out that such sequences have a natural interpretation from the view point of data structure and gave a characterization of them. Based on such a characterization, there is an algorithm to generate all LC-sequences of binary trees with n internal nodes in lexicographic order. In this paper, we extend our study to the ranking and unranking problems. By integrating a measure called “left distances” introduced by Makinen [8] to represent binary trees, we develop efficient ranking and unranking algorithms for LC-sequences in lexicographic order. With a help of aggregate analysis, we show that both ranking and unranking algorithms can be run in amortized cost of \(\mathcal {O}(n)\) time and space.

[1]  Vincent Vajnovszki,et al.  On the Loopless Generation of Binary Tree Sequences , 1998, Inf. Process. Lett..

[2]  Jou-Ming Chang,et al.  Ranking and Unranking of t-Ary Trees Using RD-Sequences , 2011, IEICE Trans. Inf. Syst..

[3]  Frank Ruskey,et al.  A CAT algorithm for generating permutations with a fixed number of inversions , 2003, Inf. Process. Lett..

[4]  Donald E. Knuth,et al.  The Art of Computer Programming, Volume 4, Fascicle 2: Generating All Tuples and Permutations (Art of Computer Programming) , 2005 .

[5]  Alexander Golynski Optimal lower bounds for rank and select indexes , 2007, Theor. Comput. Sci..

[6]  Ming-Tat Ko,et al.  Ranking and Unranking of Non-regular Trees in Gray-Code Order , 2013, IEICE Trans. Fundam. Electron. Commun. Comput. Sci..

[7]  Gideon Ehrlich,et al.  Loopless Algorithms for Generating Permutations, Combinations, and Other Combinatorial Configurations , 1973, JACM.

[8]  Erkki Mäkinen,et al.  Left distance binary tree representations , 1987, BIT.

[9]  Erkki Mäkinen,et al.  A Survey on Binary Tree Codings , 1991, Comput. J..

[10]  Dominique Roelants van Baronaigien A Loopless Algorithm for Generating Binary Tree Sequences , 1991, Inf. Process. Lett..

[11]  M. C. Er Lexicographic Listing and Ranking of t-Ary Trees , 1987, Comput. J..

[12]  Frank Ruskey,et al.  Generating Binary Trees Lexicographically , 1977, SIAM J. Comput..

[13]  Shmuel Zaks,et al.  Generating Trees and Other Combinatorial Objects Lexicographically , 1979, SIAM J. Comput..

[14]  Jou-Ming Chang,et al.  Loopless Generation of Non-regular Trees with a Prescribed Branching Sequence , 2010, Comput. J..

[15]  Frank Ruskey,et al.  Binary Tree Gray Codes , 1985, J. Algorithms.

[16]  Frank Ruskey,et al.  On Rotations and the Generation of Binary Trees , 1993, J. Algorithms.

[17]  Jou-Ming Chang,et al.  A linear time algorithm for binary tree sequences transformation using left-arm and right-arm rotations , 2006, Theor. Comput. Sci..

[18]  James F. Korsh,et al.  A loopless Gray code for rooted trees , 2006, TALG.

[19]  Kung-Jui Pai,et al.  A loopless algorithm for generating multiple binary tree sequences simultaneously , 2014, Theor. Comput. Sci..

[20]  Jou-Ming Chang,et al.  Ranking and Unranking t-ary Trees in a Gray-Code Order , 2013, Comput. J..

[21]  Anthony E. Trojanowski Ranking and Listing Algorithms for k-ary Trees , 1978, SIAM J. Comput..

[22]  Joe Sawada,et al.  Generating Bracelets in Constant Amortized Time , 2001, SIAM J. Comput..

[23]  Shmuel Zaks,et al.  Lexicographic Generation of Ordered Trees , 1980, Theor. Comput. Sci..

[24]  Carla Savage,et al.  A Survey of Combinatorial Gray Codes , 1997, SIAM Rev..

[25]  Gonzalo Navarro,et al.  Rank and select revisited and extended , 2007, Theor. Comput. Sci..

[26]  Changjie Tang,et al.  Efficient loopless generation of Gray codes for k-ary trees , 2000, Inf. Process. Lett..

[27]  Jou-Ming Chang,et al.  Ranking and unranking of non-regular trees with a prescribed branching sequence , 2011, Math. Comput. Model..

[28]  Jean Marcel Pallo,et al.  Enumerating, Ranking and Unranking Binary Trees , 1986, Comput. J..