Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started