Skip to main content
Log in

A linear-time algorithm for the generation of trees

  • Published:
Algorithmica Aims and scope Submit manuscript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  • [A] L. Alonso, Uniform generation of a Motzkin word,Theoret. Comput. Sci., 134(2):529–536, 1994.

    Article  MATH  MathSciNet  Google Scholar 

  • [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.

    Article  MATH  MathSciNet  Google Scholar 

  • [DZ2] N. Dershowitz, S. Zaks, The Cycle Lemma and some applications,European J. Combin., 11:35–40, 1990.

    MATH  MathSciNet  Google Scholar 

  • [DM] A. Dvoretzky, Th. Motzkin, A problem of arrangements,Duke Math. J., 24:305–313, 1947.

    Article  MathSciNet  Google Scholar 

  • [FZC] P. Flajolet, P. Zimmermann, B. V. Cutsem, A calculus for the generation of combinatorial structures,Theoret. Comput. Sci., 132:1–35, 1994.

    Article  MATH  MathSciNet  Google Scholar 

  • [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.

    MATH  Google Scholar 

  • [SC] M. P. Schützenberger, Context-free languages and pushdown automata,Inform. Control, 6:246–261, 1963.

    Article  MATH  Google Scholar 

  • [SI] D. M. Silberger, Occurrences of the integer (2n−2)!/n!(n−1)!,Roczniki Polskiego Towarzystwa Math. I, (13):91–96, 1969.

    MathSciNet  Google Scholar 

  • [VIT] J. S. Vitter, Optimum algorithms for two random sampling problems,Proc. FOCS 83, pp. 65–75, 1983.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Additional information

Communicated by C. L. Liu.

Rights and permissions

Reprints 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

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF02522824

Key Words

Navigation