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.
(k, m)-ary trees Tree generation Ranking Unranking
Mathematics Subject Classification
Primary 05c05 Secondary 68w32, 05c85
This is a preview of subscription content, log in to check access.
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)MathSciNetCrossRefGoogle Scholar
Ahrabian, H., Nowzari-Dalini, A.: Parallel generation of \(t\)-ary trees in A-order. Comput. J. 50, 581–588 (2007)CrossRefGoogle Scholar
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)MathSciNetzbMATHGoogle Scholar
Amani, M., Nowzari-Dalini, A.: Ranking and unranking algorithm for neuronal trees in B-order. J. Phys. Sci. 20, 19–34 (2015)MathSciNetGoogle Scholar
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)CrossRefGoogle Scholar
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)MathSciNetCrossRefGoogle Scholar
Vajnovszki, V.: Listing and random generation of neuronal trees coded by six letters. Autom. Comput. Appl. Math. 4, 29–40 (1995)MathSciNetGoogle Scholar
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)MathSciNetzbMATHGoogle Scholar
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)MathSciNetCrossRefGoogle Scholar
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)MathSciNetCrossRefGoogle Scholar