|
Non-Programming Exercises:
C(n, 0) = 1, for all n C(n, n) = 1, for all n C(n, k) = C(n-1, k-1) + C(n-1, k), for n > k and k > 0
This example is on pages 277-278 of your text, but you are not to use the book's algorithm on page 278 (no credit for this) but you must use memoization as illustrated in the program Fibonacci numbers. As in this example, you should calculate without memoization, counting the number of recursive calls, and compute with memoization, counting the number of insertions into an array. In this case you will need to use a 2-dimensional array. Try this for n = 5, k = 3; n = 10, k = 6; n = 20, k = 10; n = 25, k = 14; n = 30, k = 15. [Partial answer: C(20, 10) = 184756.]
X(1) = 1 X(n) = Sum (X(i)*X(n-i)), where the sum goes for i from 1 to n-1(Note: earlier the formula above had a 1 where an i should have been.)
It turns out that the formula for X(n) is:
X(n + 1) = (1/(n+1)) C(2n, n),
where this is the same C in the previous problem. Use the results of the previous problem to find X(11) and X(16). [Partial answer: X(11) = 16796.]