Skip to main content

A Constant Amortized Time Algorithm for Generating Left-Child Sequences in Lexicographic Order

  • 480 Accesses

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

Abstract

Wu et al. (Theoret. Comput. Sci. 556:25–33, 2014) recently introduced a new type of sequences, called left-child sequences (LC-sequences for short), for representing binary trees. 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 this characterization, Pai et al. (International conference on combinatorial optimization and applications. Springer, Cham, pp. 505–518, 2016) showed that there is an easily implementing algorithm that uses generate-and-test approach to filter all LC-sequences of binary trees with n internal nodes in lexicographic order, while in general this algorithm is not efficient at all. In this paper, we design two novel rotations that allow us to drastically alter the shape of binary trees (and thus their corresponding LC-sequences). As an application, these operations can be employed to generate all LC-sequences in lexicographic order. Accordingly, we present a more efficient algorithm associated with the new types of rotations for generating all LC-sequences and show that it takes only constant amortized running cost.

Keywords

  • Constant amortized time algorithm
  • Binary trees
  • Left-child sequences
  • Lexicographic order
  • Generation algorithms
  • Amortized cost

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • DOI: 10.1007/978-3-319-59605-1_20
  • Chapter length: 12 pages
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
eBook
USD   54.99
Price excludes VAT (USA)
  • ISBN: 978-3-319-59605-1
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
Softcover Book
USD   69.99
Price excludes VAT (USA)
Fig. 1.
Fig. 2.
Fig. 3.
Fig. 4.
Fig. 5.

References

  1. Adamchuk, A.: A014138. The On-Line Encyclopedia of Integer Sequences (2006). http://oeis.org/A014138

  2. Boyer, J.M.: Simple constant amortized time generation of fixed length numeric partitions. J. Algorithms 54, 31–39 (2005)

    CrossRef  MathSciNet  MATH  Google Scholar 

  3. Effler, S., Ruskey, F.: A CAT algorithm for generating permutations with a fixed number of inversions. Inform. Process. Lett. 86, 107–112 (2003)

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

  5. Gibbons, A., Sant, P.: Rotation sequences and edge-colouring of binary tree pairs. Theor. Comput. Sci. 326, 409–418 (2004)

    CrossRef  MathSciNet  MATH  Google Scholar 

  6. Guibas, L., Hershberger, J., Suri, S.: Morphing simple polygons. Discret. Comput. Geometry 24, 1–34 (2000)

    CrossRef  MathSciNet  MATH  Google Scholar 

  7. Hershberger, J., Suri, S.: Morphing binary trees. In: Proceedings of the ACM-SIAM Sixth Annual Symposium on Discrete Algorithms (SODA), pp. 396–404 (1995)

    Google Scholar 

  8. Kensler, A.: Tree rotations for improving bounding volume hierarchies. In: IEEE Symposium on Interactive Ray Tracing, pp. 73–76. IEEE Computer Society, Washington (2008)

    Google Scholar 

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

    MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

  12. Pai, K.-J., Wu, R.-Y., Chang, J.-M., Chang, S.-C.: Amortized efficiency of ranking and unranking left-child sequences in lexicographic order. In: Chan, T.H., Li, M., Wang, L. (eds.) COCOA 2016. LNCS, vol. 10043, pp. 505–518. Springer, Cham (2016). doi:10.1007/978-3-319-48749-6_37

    CrossRef  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

  16. Ruskey, F., Hu, T.C.: Generating binary trees lexicographically. SIAM J. Comput. 6, 745–758 (1977)

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

  20. Wu, R.-Y., Chang, J.-M., Chan, H.-C., Pai, K.-J.: A loopless algorithm for generating multiple binary tree sequences simultaneously. Theoret. Comput. Sci. 556, 25–33 (2014)

    CrossRef  MathSciNet  MATH  Google Scholar 

  21. 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. Theoret. Comput. Sci. 355, 303–314 (2006)

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

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

    CrossRef  MathSciNet  MATH  Google Scholar 

  24. Zumkeller, R.: A014138. The On-Line Encyclopedia of Integer Sequences (2010). http://oeis.org/A014138

Download references

Acknowledgments

This research was partially supported by MOST grants MOST 105-2221-E-131-027 (Kung-Jui Pai), 104-2221-E-141-002-MY3 (Jou-Ming Chang) and 104-2221-E-262-005 (Ro-Yu Wu) from the Ministry of Science and Technology, Taiwan.

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

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Pai, KJ., Chang, JM., Wu, RY. (2017). A Constant Amortized Time Algorithm for Generating Left-Child Sequences in Lexicographic Order. In: Xiao, M., Rosamond, F. (eds) Frontiers in Algorithmics. FAW 2017. Lecture Notes in Computer Science(), vol 10336. Springer, Cham. https://doi.org/10.1007/978-3-319-59605-1_20

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-59605-1_20

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-59604-4

  • Online ISBN: 978-3-319-59605-1

  • eBook Packages: Computer ScienceComputer Science (R0)