§ Integer partitions: Recurrence
An integer partition of an integer n is a sequence of numbers p[1],p[2],…p[n] which
is weakly decreasing: so we have p[1]≥p[2]⋯≥p[n]. For example, these
are the integer partitions of 5:
- [5 ]
- [4, 1 ]
- [3, 2 ]
- [3, 1, 1 ]
- [2, 2, 1 ]
- [2, 1, 1, 1 ]
- [1, 1, 1, 1, 1 ]
Thus, P(5)=7. We denote by P(n,k) the number of partitions of n into k parts.
So we have P(5,1)=1, P(5,2)=2, P(5,3)=2, P(5,4)=1, P(5,5)=1.
The recurrence for partitions is:
P(n,k)=P(n−1,k−1)+P(n−k,k)
The idea is to consider a partition p[1],p[2],…,p[k] of n based on the final element:
- if p[k]=1, then we get a smaller partition by removing the kth part, giving us a partition of (n−1)as [p[1],p[2],…,p[k−1]]. Here the number decreases from n↦(n−1) and the number of parts decreases from k↦(k−1).
- if p[k]=1 (that is, p[k]>1), then we get a partition of n−k by knocking off a 1 from each partition, giving us [p[1]−1,p[2]−1,…,p[k]−1]. Here we decrement on the number n↦n−k while still keeping the same number of parts.
§ References