Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++(recursion): Bionomial Coefficients: In probability and statistics applicatio

ID: 3931419 • Letter: C

Question

C++(recursion):

Bionomial Coefficients:

In probability and statistics applications, you often need to know the total possible number of certain outcome combinations. For example, you may want to know how many ways a 2-card BlackJack hand can be dealt from a 52 card deck, or you may need to know the number of possible committees of 3 people that can be formed from a 12-person department, etc. The binomial coefficient (often referred to as "n choose k") will provide the number of combinations of k things that can be formed from a set of n things. The binomial coefficient is written mathematically as:

which we refer to as "n choose k". Binomial coefficients can be defined recursively:

Individually, write a recursive function named choose(int n,int k) that will compute and return the value of the binomial coefficient. Then compare your function to your partner’s, and together (i) come up with a function implementation you both agree on, and (ii) write it as a C++ function on the computer.

Explanation / Answer

public static int C(int n, int k)
{
if(k == 0)
return 1;
else if(k > n)
return 0;
return C(n-1, k) + C(n-1, k-1);
}
pu

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote