A Unified Approach to Algorithms Generating Unrestricted and Restricted Integer Compositions and Integer Partitions

  • John Douglas (J.D.) OpdykeEmail author


An original algorithm is presented that generates both restricted integer compositions and restricted integer partitions that can be constrained simultaneously by (a) upper and lower bounds on the number of summands (“parts”) allowed, and (b) upper and lower bounds on the values of those parts. The algorithm can implement each constraint individually, or no constraints to generate unrestricted sets of integer compositions or partitions. The algorithm is recursive, based directly on very fundamental mathematical constructs, and given its generality, reasonably fast with good time complexity. A general, closed form solution to the open problem of counting the number of integer compositions doubly restricted in this manner also is presented; its formulaic link to an analogous solution for counting doubly-restricted integer partitions is shown to mirror the algorithmic link between these two objects.


Integer compositions Integer partitions Bounded compositions Bounded partitions Pascal’s triangle Fibonacci 

Mathematics Subject Classifications (2000)

05A07 11P82 11Y16 11Y55 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Andrews, G.: The Theory of Partitions. Cambridge University Press, Cambridge (1998)zbMATHGoogle Scholar
  2. 2.
    Beyer, T., Swinehart, D.: Algorithm 448: number of multiply-restricted partitions. Commun. ACM 16(7), 379 (1973)CrossRefGoogle Scholar
  3. 3.
    Chinn, P., Heubach, S.: Compositions of n with no occurrence of k. Congressus Numerantium 164, 33–51 (2003)zbMATHMathSciNetGoogle Scholar
  4. 4.
    Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. ACM 20, 500–513 (1973)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Grimaldi, R.: Compositions without the summand 1. Congressus Numerantium 152, 33–43 (2001)zbMATHMathSciNetGoogle Scholar
  6. 6.
    Heubach, S., Mansour, T.: Compositions of n with parts in a set. Congressus Numerantium 168, 127–143 (2004)zbMATHMathSciNetGoogle Scholar
  7. 7.
    Kimberling, C.: Enumeration of paths, compositions of integers, and Fibonacci numbers. Fibonacci Q. 39(6) (2001)Google Scholar
  8. 8.
    Kimberling, C.: Path-counting and Fibonacci numbers. Fibonacci Q. 40(4) (2002)Google Scholar
  9. 9.
    Klingsberg, P.: A gray code for compositions. J. Algorithms 3, 41–44 (1982)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Koepf, W.: Hypergeometric Summation: An Algorithmic Approach to Summation and Special Function Identities. Vieweg, Braunschweig (1998)zbMATHGoogle Scholar
  11. 11.
    Knuth, D., Szwarcfiter, J.: A structured program to generate all topological sorting arrangements. Inf. Process. Lett. 2, 153–157 (1974)zbMATHCrossRefGoogle Scholar
  12. 12.
    Knuth, D.: The Stanford Graphbase. ACM, New York (1994)zbMATHGoogle Scholar
  13. 13.
    Knuth, D.: The Art of Computer Programming. Addison-Wesley, Reading (1997)Google Scholar
  14. 14.
    Ruskey, F.: Combinatorial Generation. Working Version (1j-CSC 425/520) (2003)Google Scholar
  15. 15.
    Sanchis, L., Squire, M.: Parallel algorithms for counting and randomly generating integer partitions. J. Parallel Distrib. Comput. 34(1), 29–35 (1996)CrossRefGoogle Scholar
  16. 16.
    Sloan, N.J.A. (ed.): The online encyclopedia of integer sequences. (2008)
  17. 17.
    Stojmenovic, I.: Generating all and random instances of a combinatorial object. In: Nayak, A., Stojmenovic, I. (eds.) Handbook of Applied Algorithms: Solving Scientific, Engineering and Practical Problems. Wiley, New York (2008)Google Scholar
  18. 18.
    Uppuluri, V., Carpenter, J.: A problem of restricted partitions. Nav. Res. Logist. Q. 21(1), 201–205 (2006)CrossRefMathSciNetGoogle Scholar
  19. 19.
    Walsh, T.: Loop-free sequencing of bounded integer compositions. J. Comb. Math. Comb. Comput. 33, 323–345 (2000)zbMATHGoogle Scholar
  20. 20.
    White, J.: Algorithm 373: number of doubly restricted partitions[A1]. Commun. ACM 13(2), 120 (1970)CrossRefGoogle Scholar
  21. 21.
    White, J.: Algorithm 374: restricted partition generator[A1]. Commun. ACM 13(2), 120 (1970)CrossRefGoogle Scholar
  22. 22.
    Yamanaka, K., et al.: Constant time generation of integer partitions. IEICE Trans. Fundam. E90-A(6) (2007)Google Scholar
  23. 23.
    Zoghbi, A., Stojmenovic, I.: Fast algorithms for generating integer partitions. Int. J. Comput. Math. 70, 319–332 (1998)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer Science+Business Media B.V. 2009

Authors and Affiliations

  1. 1.DataMineItMarbleheadUSA
  2. 2.Correlation VenturesSan DiegoUSA

Personalised recommendations