Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 49 (1 point) Which recursive case will allow for the function given bel

ID: 3918044 • Letter: Q

Question

Question 49 (1 point)

Which recursive case will allow for the function given below to return the factorial of n?

int f(int n){

            if(n > 2)

                        return ???;

            else

                        return n;

}

Question 49 options:

n*f(n-1)

f(n-1)*(n-1)

n

n*(n-1)

Save

Question 50 (1 point)

The order of growth for the depth of recursion associated with the above recursive factorial (returns n!) function is:

Question 50 options:

O(1)

O(log N)

O(N)

O(N^2)

n*f(n-1)

f(n-1)*(n-1)

n

n*(n-1)

Explanation / Answer

Question 49: n*f(n-1)
This is because for factorial, we need to calcultate n*(n-1)*(n-2)*....1.
f(n-1) will give us factorial of n-1, and we multiply with n to get factorial of n.

Question 50:O(N)
This is because, for each factorial, we are doing only one function call, in which only constant execution takes place. So for N, we make N function calls, with constant execution in each call, so O(N).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote