Abstract
In this paper, we present a new generation algorithm with corresponding ranking and unranking algorithms for (k, m)-ary trees in B-order. (k, m)-ary tree is introduced by Du and Liu. A (k, m)-ary tree is a generalization of k-ary tree, whose every node of even level of the tree has degree k and odd level of the tree has degree 0 or m. Up to our knowledge no generation, ranking or unranking algorithms are given in the literature for this family of trees. We use Zaks’ encoding for representing (k, m)-ary trees and to generate them in B-order. We also prove that, to generate (k, m)-ary trees in B-order using this encoding, the corresponding codewords should be generated in reverse-lexicographical ordering. The presented generation algorithm has a constant average time and O(n) time complexity in the worst case. Due to the given encoding, both ranking and unranking algorithms are also presented taking O(n) and \(O(n\log n)\) time complexity, respectively.
Similar content being viewed by others
References
Ahmadi-Adl, A., Nowzari-Dalini, A., Ahrabian, H.: Ranking and unranking algorithms for loopless generation of \(t\)-ary trees. Logic J. IGPL 19, 33–43 (2011)
Ahrabian, H., Nowzari-Dalini, A.: Parallel generation of \(t\)-ary trees in A-order. Comput. J. 50, 581–588 (2007)
Amani, M., Nowzari-Dalini, A., Ahrabian, H.: Generation of neuronal trees by a new three letters encoding. Comput. Inform. J. 33(6), 1428–1450 (2014)
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 Proc. DCM 2015. Electron. Proc. Theor. Comput. Sci. 204, 31–45 (2015)
Amani, M.: Gap terminology and related combinatorial properties for AVL trees and Fibonacci-isomorphic trees. AKCE Int. J. Graphs Comb. 15(1), 14–21 (2018)
Du, R.R.X., Liu, F.: \((k, m)\)-Catalan numbers and hook length polynomials for plane trees. Eur. J. Comb. 28, 1312–1321 (2007)
Durocher, S., Li, P.C., Mondal, D., Ruskey, F., Williams, A.: Cool-lex order and k-ary Catalan structures. J. Discrete Algorithms 16, 287–307 (2012)
Heubach, S., Li, N., Mansour, T.: Staircase tilings and \(k\)-Catalan structures. Discrete Math. 308, 5954–5964 (2008)
Joichi, J.I., White, D.E., Williamson, S.G.: Combinatorial Gray codes. SIAM J. Comput. 9, 130–141 (1980)
Korsh, J.F., LaFollette, P.: Loopless generation of Gray codes for \(k\)-ary trees. Inf. Process. Lett. 70, 7–11 (1999)
Kreher, D.L., Stinson, D.R.: Combinatorial Algorithms, 2nd edn. CRC Press, New York (1999)
Li, L.: Ranking and unranking AVL trees. SIAM J. Comput. 15, 1025–1035 (1986)
Pallo, J.: Enumerating, ranking and unranking binary trees. Comput. J. 29, 171–175 (1986)
Pallo, J.: Generating trees with \(n\) nodes and \(m\) leaves. Int. J. Comput. Math. 21, 133–144 (1987)
Pallo, J.: A simple algorithm for generating neuronal dendritic trees. Comput. Methods Program Biomed. 33, 165–169 (1990)
van Baronaigien, D.R.: A loopless algorithm for generating binary trees sequences. Inf. Process. Lett. 39, 189–194 (1991)
van Baronaigien, D.R., Ruskey, F.: Generating \(t\)-ary trees in A-order. Inf. Process. Lett. 27, 205–213 (1988)
van Baronaigien, D.R.: A loopless Gray code algorithm for listing \(k\)-ary trees. J. Algorithms 35, 100–107 (2000)
Ruskey, F.: Generating \(t\)-ary trees lexicographically. SIAM J. Comput. 7, 424–439 (1978)
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)
Solomon, M., Finkel, R.A.: A note on enumerating binary trees. J. ACM 27, 3–5 (1980)
Stanley, R.P.: Enumerative Combinatorics, vol. 2. Cambridge University Press, Cambridge (1999)
Stojmenovic, I.: Listing combinatorial objects in parallel. Int. J. Parallel Emerg. Distrib. Syst. 21, 127–146 (2006)
Vajnovszki, V.: Listing and random generation of neuronal trees coded by six letters. Autom. Comput. Appl. Math. 4, 29–40 (1995)
Vajnovszki, V., Pallo, J.: Generating binary trees in A-order from codewords defined on four-letter alphabet. J. Inf. Optim. Sci. 15, 345–357 (1994)
Wu, R., Chang, J., Wang, Y.: A linear time algorithm for binary tree sequences transformation using left-arm and right-arm rotations. Theor. Comput. Sci. 335, 303–314 (2006)
Wu, R., Chang, J., Chang, C.: Ranking and unranking of non-regular trees with a prescribed branching sequence. Math. Comput. Modell. 53, 1331–1335 (2011)
Zaks, S.: Lexicographic generation of ordered trees. Theor. Comput. Sci. 10, 63–82 (1980)
Author information
Authors and Affiliations
Corresponding author
Additional information
Communicated by Hossein Hajiabolhassan.
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
About this article
Cite this article
Amani, M., Nowzari-Dalini, A. Efficient Generation, Ranking, and Unranking of (k, m)-Ary Trees in B-Order. Bull. Iran. Math. Soc. 45, 1145–1158 (2019). https://doi.org/10.1007/s41980-018-0190-y
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s41980-018-0190-y