Binomial distribution. Estimate the number of recursive calls that would be used by the code
public static double binomial(int n, int k){ if ((n == 0) && (k == 0)) return 1.0; if ((n < 0) || (k < 0)) return 0.0; return (binomial(n-1, k) + binomial(n-1, k−l))/2.0;}
to compute binomial (100, 50). Develop a better implementation that is based on dynamic programming. Hint: See EXERCISE 1.4.41.
EXERCISE 1.4.41.
Binomial coefficients. Write a program that takes an integer command-line argument n and creates a two-dimensional ragged array a[] [] such that a[n] [k] contains the probability that you get exactly k heads when you toss a fair coin n times. These numbers are known as the binomial distribution: if you multiply each element in row i by 2n, you get the binomial coefficients—the coefficients of xk in (x+1)n—arranged in Pascal’s triangle. To compute them, start with a [n] [0] = 0.0 for all n and a[l] [1] = 1.0, then compute values in successive rows, left to right, with a[n][k] = (a[n-l] [k] + a[n-l] [k-1]) / 2.0.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.