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

For c++ How many possible bridge hands are there? This question is a specific ca

ID: 3710346 • Letter: F

Question

For c++

How many possible bridge hands are there? This question is a specific case of the general question: how many combinations of X items can I make out of Y items? In the case of the bridge hand, X is 13 and Y is 52. The solution is given by the following formula: Combinations(Y, X) = Y if X = 1 1 if X = Y (Combinations(Y-1, X-1) + Combinations(Y-1, X)) if Y > X > 1 Write a recursive function that calculates the number of combinations of X items that can be made from Y items. Write a driver and answer the original questions. For this exercise you should use 7 for Y and 3 for X.

Explanation / Answer

//
#include<iostream>
using namespace std;
//recursive function for combinations()
int Combinations(int y,int x)
{
   //if x is 0 or x is y then return 1
   if(x==0||x==y)
       return 1;
   //else, run recursive function calls
   else
       return Combinations(y-1,x-1)+Combinations(y-1,x);
}
//main function
int main()
{
   //General case, i.e x items can i make out of y items
   int y=7,x=3,combi;
   cout<<" Y = "<<y<<" X = "<<x<<endl;
   combi=Combinations(y,x);
   cout<<" The Combinations are:"<<combi<<endl;
  
   //possible bridge hands
   y=52,x=13;
   cout<<" Y = "<<y<<" X = "<<x<<endl;
   combi=Combinations(y,x);
   cout<<" The Combinations are:"<<combi<<endl;
}

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