Skip to main content

Amortized Efficiency of Ranking and Unranking Left-Child Sequences in Lexicographic Order

  • Conference paper
  • First Online:
Combinatorial Optimization and Applications (COCOA 2016)

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

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.

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 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. Effler, S., Ruskey, F.: A CAT algorithm for generating permutations with a fixed number of inversions. Inf. Process. Lett. 86, 107–112 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  2. Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. ACM 20, 500–513 (1973)

    Article  MathSciNet  MATH  Google Scholar 

  3. Er, M.C.: Lexicographic listing and ranking \(t\)-ary trees. Comput. J. 30, 569–572 (1987)

    Article  MathSciNet  MATH  Google Scholar 

  4. Golynski, A.: Optimal lower bounds for rank and select indexes. Theor. Comput. Sci. 387, 348–359 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  5. Knuth, D.E.: The Art of Computer Programming: Fascicle 4A - Generating All Trees, vol. 4. Addison-Wesley, Boston (2005)

    MATH  Google Scholar 

  6. Korsh, J.F., LaFollette, P.: A loopless Gray code for rooted trees. ACM Trans. Algorithms 2, 135–152 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  7. Lucas, J.M., van Baronaigien, R., Ruskey, F.: On rotations and the generation. J. Algorithms 15, 343–366 (1993)

    Article  MathSciNet  MATH  Google Scholar 

  8. Mäkinen, E.: Left distance binary tree representations. BIT 27, 163–169 (1987)

    Article  MathSciNet  MATH  Google Scholar 

  9. Mäkinen, E.: A survey on binary tree codings. Comput. J. 34, 438–443 (1991)

    Article  MathSciNet  MATH  Google Scholar 

  10. Mäkinen, V., Navarro, G.: Rank and select revisited and extended. Theor. Comput. Sci. 387, 332–347 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  11. Pallo, J.: Enumerating, ranking and unranking binary trees. Comput. J. 29, 171–175 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  12. Proskurowski, A., Ruskey, F.: Binary tree Gray codes. J. Algorithms 6, 225–238 (1985)

    Article  MathSciNet  MATH  Google Scholar 

  13. Ruskey, F.: Generating \(t\)-ary trees lexicographically. SIAM J. Comput. 7, 424–439 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  14. Savage, C.D.: A survey of combinatorial Gray codes. SIAM Rev. 39, 605–629 (1997)

    Article  MathSciNet  MATH  Google Scholar 

  15. Sawada, J.: Generating bracelets in constant amortized time. SIAM Comput. 31, 259–268 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  16. Trojanowaki, A.E.: Ranking and listing algorithms for \(k\)-ary trees. SIAM J. Comput. 7, 492–509 (1978)

    Article  MathSciNet  Google Scholar 

  17. Vajnovszki, V.: On the loopless generation of binary tree sequences. Inf. Process. Lett. 68, 113–117 (1998)

    Article  MathSciNet  MATH  Google Scholar 

  18. van Baronaigien, D.R.: A loopless algorithm for generating binary tree sequences. Inf. Process. Lett. 39, 189–194 (1991)

    Article  MathSciNet  MATH  Google Scholar 

  19. 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  MATH  Google Scholar 

  20. 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  MATH  Google Scholar 

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

    Article  Google Scholar 

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

  23. 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  MATH  Google Scholar 

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

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

    Article  Google Scholar 

  26. Xiang, L., Ushijima, K., Tang, C.: Efficient loopless generation of Gray codes for \(k\)-ary trees. Inf. Process. Lett. 76, 169–174 (2000)

    Article  MathSciNet  MATH  Google Scholar 

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

    Article  MathSciNet  MATH  Google Scholar 

  28. Zaks, S., Richards, D.: Generating trees and other combinatorial objects lexicographically. SIAM J. Comput. 8, 73–81 (1979)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kung-Jui Pai .

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics