Solved

Consider the Following Code Snippet for Calculating Fibonacci Numbers Recursively

Question 42

Multiple Choice

Consider the following code snippet for calculating Fibonacci numbers recursively:
Int fib(int n)
{
// assumes n >= 0
If (n <= 1)
{
Return n;
}
Else
{
Return (fib(n - 1) + fib(n - 2) ) ;
}
}
Identify the terminating condition.


A) n < 1
B) n <= 1
C) fib(n - 1)
D) fib(n - 1) + fib(n - 1)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions