Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the C function below! double fact (long i) { if (i==1 || i=0) return i; else return i*fact (i-1); } a) Assuming that
Consider the C function below! double fact (long i) { if (i==1 || i=0) return i; else return i*fact (i-1); } a) Assuming that n characterizes the input size, in terms of n, what is the number S of recursive calls? Also give the asymptotic upper bound (0)). b) How would you modify (i.e., rewrite) the function fact so as to eliminate the redundant recursive calls and reduce the number S of recursive calls? c) Solve (a) after the modification of the function fact. d) In terms of n, what is the value of sum in the function funcQ2 below? What is its asymptotic upper bound (O())? In funcQ2 use the first version of fact (i.e., given in (a)). double fact (long i) { if (i=-1 || i==0) return i; else return i*fact (i-1); } funcQ2 () ( } for (i-1; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
a In the original function fact the number of recursive calls S is equal to the value of i This is b...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