An O(1) Time Algorithm for Generating Multiset Permutations

  • Tadao Takaoka
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1741)


We design an algorithm that generates multiset permutati- ons in O(1) time from permutation to permutations, using only data structures of arrays. The previous O(1) time algorithm used pointers, causing O(n) time to access an element in a permutation, where n is the size of permutations. The central idea in our algorithm is tree traversal. We associate permutations with the leaves of a tree. By traversing this tree, going up and down and making changes when necessary, we spend O(1) time from permutation to permutation. Permutations are generated in a one-dimensional array.


Time Algorithm Recursive Algorithm Solution Point Opposite Path Landing Point 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Hu, T.C. and B.N. Tien, Generating permutations with nondistinct items, Amer. Math. Monthly, 83 (1976) 193–196Google Scholar
  2. 2.
    Ko, C.W. and F. Ruskey, Generating permutations of a bag by interchanges, Info. Proc. Lett., 41 (1992) 263–269Google Scholar
  3. 3.
    Korsh, J. and S. Lipshutz, Generating multiset permutations in constant time, Jour. Algorithms, 25 (1997) 321–335Google Scholar
  4. 4.
    Lucas, J., The rotation graph of binary trees is Hamiltonian, Jour. Algorithms, 8 (1987) 503–535Google Scholar
  5. 5.
    Mikawa, K. and T. Takaoka, Generation of parenthesis strings by transpositions, Proc. the Computing: The Australasian Theory Symposium (CATS’ 97) (1997) 51–58Google Scholar
  6. 6.
    Nijenhuis, A. and H.S. Wilf, Combinatorial Mathematics, Academic Press (1975)Google Scholar
  7. 7.
    Proskurowski, A. and F. Ruskey, Generating binary trees by transpositions, Jour. Algorithms, 11 (1990) 68–84Google Scholar
  8. 8.
    Reingold, E.M., J. Nievergelt, and N. Deo, Combinatorial Algorithms, Prentice-Hall (1977)Google Scholar
  9. 9.
    Roelants van Baronaigien, D., A loopless algorithm for generating binary tree sequences, Info. Proc. Lett., 39 (1991) 189–194.Google Scholar
  10. 10.
    Ruskey, F. and D. Roelants van Baronaigien, Fast recursive algorithms for generating combinatorial objects, Congr. Numer., 41 (1984) 53–62Google Scholar
  11. 11.
    Savage, C, A survey of combinatorial Gray codes, SIAM Review, 39 (1997) 605–629Google Scholar
  12. 12.
    Takaoka, T., O(1) Time Algorithms for combinatorial generation by tree traversal, Computer Journal (to appear)(1999)Google Scholar
  13. 13.
    Vajnovski, V., On the loopless generation of binary tree sequences, Info. Proc. Lett., 68 (1998) 113–117Google Scholar
  14. 14.
    Walsh, T.R., Generation of well-formed parenthesis strings in constant worst-case time, Jour. Algorithms, 29 (1998) 165–173Google Scholar
  15. 15.
    Zerling, D., Generating binary trees by rotations, JACM, 32 (1985) 694–701Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1999

Authors and Affiliations

  • Tadao Takaoka
    • 1
  1. 1.Department of Computer ScienceUniversity of CanterburyChristchurchNew Zealand

Personalised recommendations