Reference no: EM131154881
Question:
Combinations are not concerned with order. Given a set of n distinct objects, there is only one combination containing all n objects.
If we have a set of of n objects, there are n! /((k!)(n - k)!) different ways to select k unordered objects from the set. That is, the number of combinations of k objects chosen from a set of n objects is
n!/((k!)(n - k)!)
The number of combinations is also known as the binomial coefficient.
For example, suppose we have the set { 1, 2, 3, 4) and want to choose 2 integers at a time from this set, without regard to order. There arc 4! / ((2!) (4 - 2)! ) = 6 combinations: {1, 2), {1, 3), (1, 4), {2, 3), {2, 4) and {3, 4).
An incomplete implementation of a function named binomial is provided in main.c. This function has two integer parameters, n and k, and has return type int. This function returns the number of combinations of k objects chosen from a set of n objects.
Finish the definition of this function. Your function should assume that n and k are positive and that n >= k; i.e., the function should not check if n and k are passed positive or negative values, or compare n and k.
Your binomial function must call your ordered subsets and factorial functions.
Build the project, convicting any compilation errors, then execute the project. The test harness will run. Look at the console output, and verify that your function passes all of the tests in the third test suite before you start Exercise 4.
Question: