Question: Write a C++ program to test the following two functions. Call the functions with values for n between 1 and 10. int F1(int n) {

 Write a C++ program to test the following two functions. Call

Write a C++ program to test the following two functions. Call the functions with values for n between 1 and 10. int F1(int n) { if (n == 0) return 1; return F1(n - 1) + F1(n - 1); } == int F2(int n) { if (n 0) return 1; if (n % 2 == 0) { int result = F2(n / 2); return result * result; } else return 2 * F2(n - 1); } Submit your test program and in your report answer the following questions: a. What does each function do? b. Which function is faster (hint: test them with n = 30)? C. Guess the running time growth of each function and hence explain why one function is faster than the other

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!