Abstract
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 Mäkinen [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.
Keywords
This research was partially supported by MOST grants 104-2221-E-131-004 (Kung-Jui Pai), 104-2221-E-262-005 (Ro-Yu Wu) and 104-2221-E-141-002-MY3 (Jou-Ming Chang) from the Ministry of Science and Technology, Taiwan.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Effler, S., Ruskey, F.: A CAT algorithm for generating permutations with a fixed number of inversions. Inf. Process. Lett. 86, 107–112 (2003)
Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. ACM 20, 500–513 (1973)
Er, M.C.: Lexicographic listing and ranking \(t\)-ary trees. Comput. J. 30, 569–572 (1987)
Golynski, A.: Optimal lower bounds for rank and select indexes. Theor. Comput. Sci. 387, 348–359 (2007)
Knuth, D.E.: The Art of Computer Programming: Fascicle 4A - Generating All Trees, vol. 4. Addison-Wesley, Boston (2005)
Korsh, J.F., LaFollette, P.: A loopless Gray code for rooted trees. ACM Trans. Algorithms 2, 135–152 (2006)
Lucas, J.M., van Baronaigien, R., Ruskey, F.: On rotations and the generation. J. Algorithms 15, 343–366 (1993)
Mäkinen, E.: Left distance binary tree representations. BIT 27, 163–169 (1987)
Mäkinen, E.: A survey on binary tree codings. Comput. J. 34, 438–443 (1991)
Mäkinen, V., Navarro, G.: Rank and select revisited and extended. Theor. Comput. Sci. 387, 332–347 (2007)
Pallo, J.: Enumerating, ranking and unranking binary trees. Comput. J. 29, 171–175 (1986)
Proskurowski, A., Ruskey, F.: Binary tree Gray codes. J. Algorithms 6, 225–238 (1985)
Ruskey, F.: Generating \(t\)-ary trees lexicographically. SIAM J. Comput. 7, 424–439 (1978)
Savage, C.D.: A survey of combinatorial Gray codes. SIAM Rev. 39, 605–629 (1997)
Sawada, J.: Generating bracelets in constant amortized time. SIAM Comput. 31, 259–268 (2001)
Trojanowaki, A.E.: Ranking and listing algorithms for \(k\)-ary trees. SIAM J. Comput. 7, 492–509 (1978)
Vajnovszki, V.: On the loopless generation of binary tree sequences. Inf. Process. Lett. 68, 113–117 (1998)
van Baronaigien, D.R.: A loopless algorithm for generating binary tree sequences. Inf. Process. Lett. 39, 189–194 (1991)
Wu, R.-Y., Chang, J.-M., Chan, H.-C., Pai, K.-J.: A loopless algorithm for generating multiple binary tree sequences simultaneously. Theor. Comput. Sci. 556, 25–33 (2014)
Wu, R.-Y., Chang, J.-M., Chang, C.-H.: Ranking and unranking of non-regular trees with a prescribed branching sequence. Math. Comput. Model 53, 1331–1335 (2011)
Wu, R.-Y., Chang, J.-M., Chen, A.-H., Ko, M.-T.: Ranking and unranking of non-regular trees in Gray-code order. IEICE Trans. Fund. E96–A, 1059–1065 (2013)
Wu, R.-Y., Chang, J.-M., Chen, A.-H., Liu, C.-L.: Ranking and unranking \(t\)-ary trees in a Gray-code order. Comput. J. 56, 1388–1395 (2013)
Wu, R.-Y., Chang, J.-M., Wang, Y.-L.: A linear time algorithm for binary tree sequences transformation using left-arm and right-arm rotations. Theor. Comput. Sci. 355, 303–314 (2006)
Wu, R.-Y., Chang, J.-M., Wang, Y.-L.: Loopless generation of non-regular trees with a prescribed branching sequence. Comput. J. 53, 661–666 (2010)
Wu, R.-Y., Chang, J.-M., Wang, Y.-L.: Ranking and unranking of \(t\)-ary trees using RD-sequences. IEICE Trans. Inf. Syst. E94–D, 226–232 (2011)
Xiang, L., Ushijima, K., Tang, C.: Efficient loopless generation of Gray codes for \(k\)-ary trees. Inf. Process. Lett. 76, 169–174 (2000)
Zaks, S.: Lexicographic generation of ordered trees. Theor. Comput. Sci. 10, 63–82 (1980)
Zaks, S., Richards, D.: Generating trees and other combinatorial objects lexicographically. SIAM J. Comput. 8, 73–81 (1979)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing AG
About this paper
Cite this paper
Pai, KJ., Wu, RY., Chang, JM., Chang, SC. (2016). Amortized Efficiency of Ranking and Unranking Left-Child Sequences in Lexicographic Order. In: Chan, TH., Li, M., Wang, L. (eds) Combinatorial Optimization and Applications. COCOA 2016. Lecture Notes in Computer Science(), vol 10043. Springer, Cham. https://doi.org/10.1007/978-3-319-48749-6_37
Download citation
DOI: https://doi.org/10.1007/978-3-319-48749-6_37
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-48748-9
Online ISBN: 978-3-319-48749-6
eBook Packages: Computer ScienceComputer Science (R0)