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

Use the following recursive function to answer the next three questions: int f(i

ID: 3918043 • Letter: U

Question

Use the following recursive function to answer the next three questions:

int f(int n){

            if(n < 1)

                        return 2;

            else

                        return f(n-1);

}

Question 44 (1 point)

What values of n will give the base case of the given function?

Question 44 options:

n = 0

n = 2

n = 1

n = -10

Save

Question 45 (1 point)

What is the output of f(3)?

Question 45 options:

2

4

3

This function does not give an output.

Question 46 (1 point)

What is the runtime complexity of this function?

Question 46 options:

O(N)

O(N^2)

O(1)

O(log N)

n = 0

n = 2

n = 1

n = -10

Explanation / Answer

Question 44 What values of n will give the base case of the given function?

n = 0

Question 45 What is the output of f(3)

f(3) calls f(2) , f(2) calls f(1) , f1 calls f(0) which returns 2.

2

Question 46 What is the runtime complexity of this function?

O(N)

f(n) calls f(n-1) , f(n-1) calls f(n-2) so on until f(0) which returns 2. 0 to n is (n+1) times . The constant is neglected. Therefore 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