Abstract
We present a linear algorithm which generates randomly and with uniform probability many kinds of trees: binary trees, ternary trees, arbitrary trees, forests ofp k-ary trees,.... The algorithm is based on the definition of generic trees which can be coded as words. These words, in turn, are generated in linear time.
Similar content being viewed by others
References
[A] L. Alonso, Uniform generation of a Motzkin word,Theoret. Comput. Sci., 134(2):529–536, 1994.
[AS] L. Alonso, R. Schott, A parallel algorithm for the generation of permutations, to appear inTheoret. Comput. Sci., 1996.
[DZ1] N. Dershowitz, S. Zaks, Patterns in trees,Discrete Appl. Math., 25:241–255, 1989.
[DZ2] N. Dershowitz, S. Zaks, The Cycle Lemma and some applications,European J. Combin., 11:35–40, 1990.
[DM] A. Dvoretzky, Th. Motzkin, A problem of arrangements,Duke Math. J., 24:305–313, 1947.
[FZC] P. Flajolet, P. Zimmermann, B. V. Cutsem, A calculus for the generation of combinatorial structures,Theoret. Comput. Sci., 132:1–35, 1994.
[R] J. L. Rémy, Un procédé itératif de dénombrement d'arbres binaires et son application à leur génération aléatoire,RAIRO Inform. Théor., 19(2):179–195, 1985.
[SC] M. P. Schützenberger, Context-free languages and pushdown automata,Inform. Control, 6:246–261, 1963.
[SI] D. M. Silberger, Occurrences of the integer (2n−2)!/n!(n−1)!,Roczniki Polskiego Towarzystwa Math. I, (13):91–96, 1969.
[VIT] J. S. Vitter, Optimum algorithms for two random sampling problems,Proc. FOCS 83, pp. 65–75, 1983.
Author information
Authors and Affiliations
Additional information
Communicated by C. L. Liu.
Rights and permissions
About this article
Cite this article
Alonso, L., Rémy, J.L. & Schott, R. A linear-time algorithm for the generation of trees. Algorithmica 17, 162–182 (1997). https://doi.org/10.1007/BF02522824
Received:
Revised:
Issue Date:
DOI: https://doi.org/10.1007/BF02522824