Question: You are given the following pseudocode for a recursive algorithm. Algorithm 1 Recursive Function 1 1 : Algorithm RecFunc ( n ) Input: Integer n

You are given the following pseudocode for a recursive algorithm.
Algorithm 1 Recursive Function 1
1: Algorithm RecFunc(n)
Input: Integer n
2: if n =1 then
3: return 1
4: else if n is even then
5: return 2n + RecFunc(n 1)
6: else if n is odd then
7: return n + RecFunc(n 1)
8: end if
9: end Algorithm
a. State the base and the recursive cases
b. Draw the corresponding recursion tree when RecFunc(5) is invoked.
c. Compute the return value (as an integer) of the function call RecFunc(5).
d. Determine its worst-case asymptotic running time in terms of n
e. Determine its space complexity in terms of n

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!