Question: Problem 2 (30 Points) Write a C++ program, no need to be object-oriented, to test the following three functions. Each function receives one parameter n,

 Problem 2 (30 Points) Write a C++ program, no need to

Problem 2 (30 Points) Write a C++ program, no need to be object-oriented, to test the following three functions. Each function receives one parameter n, which is a positive integer. int F1(int n) if (n == 0) return 1; if (n % 2 == 0) { int result = F1(n / 2); return result * result; else return 2 * F1(n - 1); int F2(int n) if (n == 0) return 1; return 2 * F2(n - 1); int F3(int n) if (n == 0) return 1; return F3(n - 1) + F3(n - 1); Test the functions by calling them with the following values for n: 1, 3, 5, 16, 24, 26, 30. Submit your test program and in your report answer the following questions: a. What does each function return as a function of input parameter n? b. Which function is the worst in terms of time efficiency? Support your answer by stating, without proof, the running time growth rate, as a function of n, of each of the above functions

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!