.
:
0 -> 0
1 -> 100
2 -> 11000
3 -> 10100
4 -> 1110000
5 -> 1101000
6 -> 1100100
7 -> 1011000
8 -> 1010100
, ( ) (, 1 0 ).
.
, n :
Left sub-tree n-1 nodes, Right sub-tree 0 nodes. (Cn-1*C0 of them)
Left sub-tree n-2 nodes, Right sub-tree 1 node. (Cn-2*C1 of them)
Left sub-tree n-3 nodes, right sub-tree 2 nodes. (Cn-3*C2 of them)
...
...
Left sub-tree 0 nodes, Right sub-tree n-1 nodes. (C0*Cn-1 of them)
Cr = rth catalan number.
, , , : , . , . , -1 ..
, , id = S. n,
C0 + C1 + C2 +... + Cn < S <= C0 + C1 + C2 +... + Cn + 1
S n + 1 .
, P = S - (C0 + C1 + C2 +... + Cn), n + 1 .
r , Cn * C0 + Cn-1 * C1 +.. + Cn-rCr < P <= CnC0 + Cn-1 * C1 +.. + Cn-r + 1 * Cr-1
, .
P-Cn * C0 + Cn-1 * C1 +.. + Cn-r * Cr, ( ) .
, , , , , , .
, . .
Aryabhatta