Question: 1 (a) Given the following function (in pseudo-code), with n as an input parameter and n is a positive number: int function f(n) { if

1 (a) Given the following function (in pseudo-code), with n as an input parameter and n is a positive number:

int function f(n)

{

if n <= 3 then return 0

else

{

sum=f(n-3)+f(n-2)+f(n-1)

for i=1 to n do

{

for j=1 to n do

{

sum=sum+i*j

}

}

}

return sum

}

Let T(n) be the time complexity of f(n). Write a recurrence relation for T(n). You do not need to solve the recurrence, but be precise in its definition.

1 (b) Show the recursion tree for the above algorithm for computing f(5). Obtain the value of f(5). Show all your derivations.

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!