Advertisement

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

  • Kung-Jui Pai
  • Jou-Ming ChangEmail author
  • Ro-Yu Wu
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, 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 

Notes

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.

References

  1. 1.
    Adamchuk, A.: A014138. The On-Line Encyclopedia of Integer Sequences (2006). http://oeis.org/A014138
  2. 2.
    Boyer, J.M.: Simple constant amortized time generation of fixed length numeric partitions. J. Algorithms 54, 31–39 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Effler, S., Ruskey, F.: A CAT algorithm for generating permutations with a fixed number of inversions. Inform. Process. Lett. 86, 107–112 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. ACM 20, 500–513 (1973)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Gibbons, A., Sant, P.: Rotation sequences and edge-colouring of binary tree pairs. Theor. Comput. Sci. 326, 409–418 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Guibas, L., Hershberger, J., Suri, S.: Morphing simple polygons. Discret. Comput. Geometry 24, 1–34 (2000)MathSciNetCrossRefzbMATHGoogle Scholar
  7. 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. 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. 9.
    Knuth, D.E.: The Art of Computer Programming. Fascicle 4A - Generating All Trees, vol. 4. Addison-Wesley, Boston (2005)zbMATHGoogle Scholar
  10. 10.
    Lucas, J.M., van Baronaigien, D.R., Ruskey, F.: On rotations and the generation of binary trees. J. Algorithms 15, 343–366 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Mäkinen, E.: A survey on binary tree codings. Comput. J. 34, 438–443 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 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 CrossRefGoogle Scholar
  13. 13.
    Pallo, J.: Enumerating, ranking and unranking binary trees. Comput. J. 29, 171–175 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Proskurowski, A., Ruskey, F.: Binary tree Gray codes. J. Algorithms 6, 225–238 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    van Baronaigien, D.R.: A loopless algorithm for generating binary tree sequences. Inform. Process. Lett. 39, 189–194 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Ruskey, F., Hu, T.C.: Generating binary trees lexicographically. SIAM J. Comput. 6, 745–758 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Savage, C.D.: A survey of combinatorial Gray codes. SIAM Rev. 39, 605–629 (1997)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Sawada, J.: Generating bracelets in constant amortized time. SIAM Comput. 31, 259–268 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  19. 19.
    Vajnovszki, V.: On the loopless generation of binary tree sequences. Inform. Process. Lett. 68, 113–117 (1998)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  21. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Zaks, S.: Lexicographic generation of ordered trees. Theoret. Comput. Sci. 10, 63–82 (1980)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Zaks, S., Richards, D.: Generating trees and other combinatorial objects lexicographically. SIAM J. Comput. 8, 73–81 (1979)MathSciNetCrossRefzbMATHGoogle Scholar
  24. 24.
    Zumkeller, R.: A014138. The On-Line Encyclopedia of Integer Sequences (2010). http://oeis.org/A014138

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  1. 1.Department of Industrial Engineering and ManagementMing Chi University of TechnologyNew Taipei CityTaiwan
  2. 2.Institute of Information and Decision SciencesNational Taipei University of BusinessTaipeiTaiwan
  3. 3.Department of Industrial ManagementLunghwa University of Science and TechnologyTaoyuanTaiwan

Personalised recommendations