A given nondecreasing sequence can be represented by a sequence of I's and U's, where I represents the placement of an integer and U represents going up by 1 unit in value as the current value to be placed at any given I. Any U's that occur before the first I increase the value of the first integer. If the last integer is lower than n, then the remaining U's occur after the last I.
Thus there are n U's to take the values from 0 to n, and n+1 I's as there are n+1 integers. The number of such sequences of U's and I's is C(2n+1,n). In the sample case, where n=2, this is C(5,2) = 10, and the correspondence of the two types of sequence is shown:
000 IIIUU
001 IIUIU
002 IIUUI
011 IUIIU
012 IUIUI
022 IUUII
111 UIIIU
112 UIIUI
122 UIUUI
222 UUIII

Posted by Charlie
on 20100504 17:32:31 