Skip to main content

Improved Algorithms for Ranking and Unranking (km)-Ary Trees

  • Conference paper
  • First Online:
Book cover Algorithmic Aspects in Information and Management (AAIM 2019)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 11640))

Included in the following conference series:

  • 510 Accesses

Abstract

Du and Liu (2007) introduced (km)-ary trees as a generalization of k-ary trees. In a (km)-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 (km)-ary tree of order n has exactly n crucial nodes. Recently, Amani and Nowzari-Dalini (2019) presented a generation algorithm to produce all (km)-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 (km)-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 (km)-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 (km)-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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Amani, M.: Gap terminology and related combinatorial properties for AVL trees and Fibonacci-isomorphic trees. AKCE Int. J. Graphs Comb. 15, 14–21 (2018)

    Article  MathSciNet  Google Scholar 

  2. 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

  3. Amani, M., Nowzari-Dalini, A.: Ranking and unranking algorithm for neuronal trees in B-order. J. Phys. Sci. 20, 19–34 (2015)

    MathSciNet  Google Scholar 

  4. 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)

    Article  MathSciNet  Google Scholar 

  5. Amani, M., Nowzari-Dalini, A., Ahrabian, H.: Generation of neuronal trees by a new three letters encoding. Comput. Inform. J. 33, 1428–1450 (2014)

    MathSciNet  MATH  Google Scholar 

  6. Du, R.R.X., Liu, F.: \((k, m)\)-Catalan numbers and hook length polynomials for plane trees. Euro. J. Combin. 28, 1312–1321 (2007)

    Article  MathSciNet  Google Scholar 

  7. Li, L.: Ranking and unranking AVL trees. SIAM J. Comput. 15, 1025–1035 (1986)

    Article  MathSciNet  Google Scholar 

  8. 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

  9. Pallo, J.: Generating trees with \(n\) nodes and \(m\) leaves. Int. J. Comput. Math. 21, 133–144 (1987)

    Article  Google Scholar 

  10. 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)

    Article  MathSciNet  Google Scholar 

  11. Stanley, R.P.: Enumerative Combinatorics, vol. 2. Cambridge University Press, Cambridge (1999)

    Book  Google Scholar 

  12. 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)

    Article  MathSciNet  Google Scholar 

  13. 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)

    Article  MathSciNet  Google Scholar 

  14. 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)

    Article  Google Scholar 

  15. 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)

    Article  MathSciNet  Google Scholar 

  16. 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)

    Article  Google Scholar 

  17. 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)

    Article  Google Scholar 

  18. Zaks, S.: Lexicographic generation of ordered trees. Theor. Comput. Sci. 10, 63–82 (1980)

    Article  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jou-Ming Chang .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Chang, YH., Wu, RY., Chang, RS., Chang, JM. (2019). Improved Algorithms for Ranking and Unranking (km)-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)

Publish with us

Policies and ethics