Abstract
Du and Liu (2007) introduced (k, m)-ary trees as a generalization of k-ary trees. In a (k, m)-ary tree, every node on even level has degree k (i.e., has k children), and every node on odd level has degree m (which is called a crucial node) or is a leaf. In particular, a (k, m)-ary tree of order n has exactly n crucial nodes. Recently, Amani and Nowzari-Dalini (2019) presented a generation algorithm to produce all (k, m)-ary trees of order n in B-order using Zaks’ encoding, and show that the generated ordering of this encoding results in a reverse-lexicographical ordering. They also proposed the corresponding ranking and unranking algorithms for (k, m)-ary trees according to such a generated ordering. These algorithms take \({\mathcal {O}}(kmn^2)\) time and space for building a precomputed table in which (k, m)-Catalan numbers (i.e., a kind of generalized Catalan numbers) are stored in advance. In this paper, we revisit the ranking and unranking problems. With the help of an encoding scheme called “right-distance” introduced by Wu et al. (2011), we propose new ranking and unranking algorithms for (k, m)-ary trees of order n in B-order using Zaks’ encoding. We show that both algorithms can be improved in \({\mathcal {O}}(kmn)\) time and \({\mathcal {O}}(n)\) space without building the precomputed table.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Amani, M.: Gap terminology and related combinatorial properties for AVL trees and Fibonacci-isomorphic trees. AKCE Int. J. Graphs Comb. 15, 14–21 (2018)
Amani, M., Nowzari-Dalini, A.: Efficient generation, ranking, and unranking of \((k,m)\)-ary trees in B-order. Bull. Iranian Math. Soc. (2019). https://doi.org/10.1007/s41980-018-0190-y
Amani, M., Nowzari-Dalini, A.: Ranking and unranking algorithm for neuronal trees in B-order. J. Phys. Sci. 20, 19–34 (2015)
Amani, M., Nowzari-Dalini, A.: Generation, ranking and unranking of ordered trees with degree bounds. In: Proceedings of DCM 2015. Electronic Proceedings in Theoretical Computer Science, vol. 204, pp. 31–45 (2015)
Amani, M., Nowzari-Dalini, A., Ahrabian, H.: Generation of neuronal trees by a new three letters encoding. Comput. Inform. J. 33, 1428–1450 (2014)
Du, R.R.X., Liu, F.: \((k, m)\)-Catalan numbers and hook length polynomials for plane trees. Euro. J. Combin. 28, 1312–1321 (2007)
Li, L.: Ranking and unranking AVL trees. SIAM J. Comput. 15, 1025–1035 (1986)
Pai, K.-J., Chang, J.-M., Wu, R.-Y., Chang, S.-C.: Amortized efficiency of generation, ranking and unranking left-child sequences in lexicographic order. Discrete Appl. Math. (2018). https://doi.org/10.1016/j.dam.2018.09.035
Pallo, J.: Generating trees with \(n\) nodes and \(m\) leaves. Int. J. Comput. Math. 21, 133–144 (1987)
Seyedi-Tabari, E., Ahrabian, H., Nowzari-Dalini, A.: A new algorithm for generation of different types of RNA. Int. J. Comput. Math. 87, 1197–1207 (2010)
Stanley, R.P.: Enumerative Combinatorics, vol. 2. Cambridge University Press, Cambridge (1999)
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., 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. Inform. Syst. E94–D, 226–232 (2011)
Zaks, S.: Lexicographic generation of ordered trees. Theor. Comput. Sci. 10, 63–82 (1980)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Chang, YH., Wu, RY., Chang, RS., Chang, JM. (2019). Improved Algorithms for Ranking and Unranking (k, m)-Ary Trees. In: Du, DZ., Li, L., Sun, X., Zhang, J. (eds) Algorithmic Aspects in Information and Management. AAIM 2019. Lecture Notes in Computer Science(), vol 11640. Springer, Cham. https://doi.org/10.1007/978-3-030-27195-4_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-27195-4_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-27194-7
Online ISBN: 978-3-030-27195-4
eBook Packages: Computer ScienceComputer Science (R0)