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





References
Adamchuk, A.: A014138. The On-Line Encyclopedia of Integer Sequences (2006). http://oeis.org/A014138
Boyer, J.M.: Simple constant amortized time generation of fixed length numeric partitions. J. Algorithms 54, 31–39 (2005)
Effler, S., Ruskey, F.: A CAT algorithm for generating permutations with a fixed number of inversions. Inform. Process. Lett. 86, 107–112 (2003)
Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. ACM 20, 500–513 (1973)
Gibbons, A., Sant, P.: Rotation sequences and edge-colouring of binary tree pairs. Theor. Comput. Sci. 326, 409–418 (2004)
Guibas, L., Hershberger, J., Suri, S.: Morphing simple polygons. Discret. Comput. Geometry 24, 1–34 (2000)
Hershberger, J., Suri, S.: Morphing binary trees. In: Proceedings of the ACM-SIAM Sixth Annual Symposium on Discrete Algorithms (SODA), pp. 396–404 (1995)
Kensler, A.: Tree rotations for improving bounding volume hierarchies. In: IEEE Symposium on Interactive Ray Tracing, pp. 73–76. IEEE Computer Society, Washington (2008)
Knuth, D.E.: The Art of Computer Programming. Fascicle 4A - Generating All Trees, vol. 4. Addison-Wesley, Boston (2005)
Lucas, J.M., van Baronaigien, D.R., Ruskey, F.: On rotations and the generation of binary trees. J. Algorithms 15, 343–366 (1993)
Mäkinen, E.: A survey on binary tree codings. Comput. J. 34, 438–443 (1991)
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
Pallo, J.: Enumerating, ranking and unranking binary trees. Comput. J. 29, 171–175 (1986)
Proskurowski, A., Ruskey, F.: Binary tree Gray codes. J. Algorithms 6, 225–238 (1985)
van Baronaigien, D.R.: A loopless algorithm for generating binary tree sequences. Inform. Process. Lett. 39, 189–194 (1991)
Ruskey, F., Hu, T.C.: Generating binary trees lexicographically. SIAM J. Comput. 6, 745–758 (1977)
Savage, C.D.: A survey of combinatorial Gray codes. SIAM Rev. 39, 605–629 (1997)
Sawada, J.: Generating bracelets in constant amortized time. SIAM Comput. 31, 259–268 (2001)
Vajnovszki, V.: On the loopless generation of binary tree sequences. Inform. Process. Lett. 68, 113–117 (1998)
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)
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)
Zaks, S.: Lexicographic generation of ordered trees. Theoret. Comput. Sci. 10, 63–82 (1980)
Zaks, S., Richards, D.: Generating trees and other combinatorial objects lexicographically. SIAM J. Comput. 8, 73–81 (1979)
Zumkeller, R.: A014138. The On-Line Encyclopedia of Integer Sequences (2010). http://oeis.org/A014138
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
Corresponding author
Editor information
Editors and Affiliations
Rights 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)