Question: A recursive function is defined by the following formula: f(n)=2f(n/2)+n2 if n is even f(n)=f(n1)+n if n is odd f(1)=1 Use the above recursive definition

A recursive function is defined by the following formula: f(n)=2f(n/2)+n2 if n is even f(n)=f(n1)+n if n is odd f(1)=1 Use the above recursive definition to write a recursive function named evaluate_ f(n) that takes a non-negative integer as a parameter and computes the tuple (f(n),k) where k is the number of recursive function calls required to compute f(n). Note: - The first function call does not count as a recursive call, e.g. for f(1), the number of recursive function calls is zero (base case, so result is returned without recursive call) and for f(2) the number of recursive function calls is 1. - You may not use loops of any kind. You must use recursion to solve this problem. You can assume that the parameter integer is non-negative. For example: Answer: (penalty regime: 0,0,5,10,15,20,25,30,35,40,45,50% )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
