Question: //*******TO DO********* #include #include using namespace std; // Suppose you have a n ounce pitcher and a l ounce glass. // The goal is to

//*******TO DO********* #include  #include  using namespace std; // Suppose you have a n ounce pitcher and a l ounce glass. // The goal is to fill the pitcher using a glass // Compute recursively how many times you should fill the glass and pour it in the pitcher // the pitcher does not need to be full. For example, if you have a 11 ounce pitcher and a 2 ounce glass, the answer is 5 int Fillpitcher(int n, int l) { //*******TO DO********* } // ##### ENUMERATING THINGS ##### // // Sometimes it's useful to _enumerate_ all elements of a set. // For instance, all binary strings of a specific length. size =3 : 000 001 010 011 100 101 110 111 // // If the length is known, can use loops like following: // void print_all_binary_strings_of_length_3() { for (int i = 0; i <= 1; ++i) { for (int j = 0; j <= 1; ++j) { for (int k = 0; k <= 1; ++k) { cout << i << j << k << endl; } } } } // // But if the length is not known (e.g. is a parameter), // then using loops is not an option. // ##### USING RECURSION TO ENUMERATE THINGS ##### // // Recursion is really good for enumerating things. // // HINT: build part of an element, let "recursion fairies" // fill in the rest in all possible ways. // // For binary strings, build partial string, // let recursion fairies fill in the remaining characters. // // Pass along partial string as a parameter. // So, the idea is that you keep creating string and pass it to the kid // void print_all_binary_strings(string partial, int n) { //*******TO DO********* } int main() { print_all_binary_strings("", 3); cout<< "you need "<< Fillpitcher(15, 2) << " glasses to fill the pitcher (7)"<                                            

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!