Answer the question
In order to leave comments, you need to log in
How does this recursive algorithm work?
Hello!
The algorithm for calculating the binomial, as I understand it, is according to the Bernouli formula.
It also uses a recurrent formula for finding the number of combinations
. The algorithm itself:
public double binomial1(int N, int k, double p) {
if (N == 0 && k == 0) return 1.0;
if (N < 0 || k < 0) return 0.0;
return (1.0 - p) *binomial1(N-1, k, p) + p*binomial1(N-1, k-1, p);
}
Answer the question
In order to leave comments, you need to log in
Do you understand the word degree ?
After all, it's just the n-th number of times the number is multiplied by itself. And the first part to the plus reproduces this. The second part after the plus is and is that plus from the formula.
Such algorithms are easily analyzed and unraveled when you start to manually substitute values. 0, 1, 2,...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question