Skip to main content
Log in

Generating a Gray Code for P-Sequences

  • Published:
Journal of Mathematical Modelling and Algorithms

Abstract

P-sequences are used for coding binary trees and they are also an alternative representation for well-formed parentheses strings. We present here the first Gray code and loopless generating algorithm for P-sequences, and extend them in a Gray code and a new loopless generating algorithm for well-formed parentheses strings. Ranking and unranking algorithms are also discussed.

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

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

    Google Scholar 

  2. Feller, W.: An Introduction to Probability Theory and its Applications, 2nd edn, Wiley, New York, 1971.

    Google Scholar 

  3. Mikawa, K. and Takaoka, T.: Generation of parenthesis strings by transpositions, In: Proc. CATS'97, Sydney, Australia, February 3-4, 1997.

  4. Pallo, J. M. and Racca, R.: A note on generating binary trees in A-order and B-order, Internat. J. Comput. Math. 18(1) (1985), 27–39.

    Google Scholar 

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

    Google Scholar 

  6. Roelants van Baronaigien, D.: A loopless Gray-code algorithm for listing k-ary trees, J. Algorithms 35(1) (2000), 100–107.

    Google Scholar 

  7. Ruskey, F. and Proskurowski, A.: Generating binary trees by transpositions, J. Algorithms 11 (1990), 68–84.

    Google Scholar 

  8. Vajnovszki, V.: Loopless algorithm for generating well-formed parentheses strings, Research Report Department IEM, University of Burgundy, Sept., 1997.

    Google Scholar 

  9. Vajnovszki, V.: On the loopless generation of binary tree sequences, Internat. Process. Lett. 68 (1998), 113–117. GENERATING A GRAY CODE FOR P-SEQUENCES 41

    Google Scholar 

  10. Walsh, T. R.: Generation of well-formed parenthesis strings in constant worst-case time, J. Algorithms 29(1) (1998), 651–673.

    Google Scholar 

  11. Walsh, T. R.: Loop-free sequencing of bounded integer compositions, J. Combin. Math. Combin. Comput. 33 (2000), 323–345.

    Google Scholar 

  12. Williamson, S. G.: Combinatorics for Computer Science, Computer Science Press, Rockville, Maryland, 1985.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Vajnovszki, V. Generating a Gray Code for P-Sequences. Journal of Mathematical Modelling and Algorithms 1, 31–41 (2002). https://doi.org/10.1023/A:1015622720041

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1015622720041

Navigation