Order from us for quality, customized work in due time of your choice.
Consider a recursive function, called f, that computes powers of 3 using only th
Consider a recursive function, called f, that computes powers of 3 using only the + operator. Assume n >= 0.
int f(int n) {
if (n == 0) return 1;
return f(n-1) + f(n-1) + f(n-1);
}
a) Write a recurrence relation for S(n), the number of addition operations performed by f(n) in terms of n.
b) Solve the recurrence from Part a to get a formula for S(n).
c) Give an optimized version of f, called g, where we save the result of the recursive call to a temporary variable t, then return t+t+t.
d) Write a recurrence relation for T(n), the number addition operations performed by g(n) in terms of n.
e) Solve the recurrence from Part d to get a formula for T(n).
Order from us for quality, customized work in due time of your choice.