Explore BrainMass

Explore BrainMass

    Writing a recursive algorithm

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    The question of how many ways a committee of 4 people can be selected from a group of 10 is known as a combination. The notation in general for counting the number of ways of selecting r items from a group of n is C(n,r) = n! / r!(n-r)!

    Also, given that 0! = 1 by definition, we can show that C(n,0) = 1 = C(n,n)

    Also, C(n,r) = C(n-1, r-1) + C(n-1, r)

    Given the information above, write a recursive algorithm to find C(n,r) for any two non-negative integers n and r, with r <= n

    © BrainMass Inc. brainmass.com November 30, 2021, 5:08 am ad1c9bdddf
    https://brainmass.com/computer-science/c/writing-recursive-algorithm-428272

    Solution Preview

    The recursive algorithm is described as below.

    int C(int n, int r) {
    // First, I check the ...

    Solution Summary

    This solution shows how to write a recursive algorithm.

    $2.49

    ADVERTISEMENT