What is the base case in a recursive Fibonacci function?
The base case returns the first two Fibonacci numbers directly: Fibonacci(0) = 0 and Fibonacci(1) = 1. This stops the recursion from continuing infinitely.
Click to reveal answer
beginner
Explain how recursion works in calculating Fibonacci numbers.
Recursion breaks the problem into smaller parts by calling the Fibonacci function for (n-1) and (n-2) until it reaches the base cases. Then it adds those results to get the Fibonacci number for n.
Click to reveal answer
intermediate
What is the time complexity of the naive recursive Fibonacci algorithm?
The time complexity is exponential, specifically O(2^n), because it recalculates the same Fibonacci numbers many times.
Click to reveal answer
beginner
Show the C# recursive function signature for Fibonacci.
public static int Fibonacci(int n)
Click to reveal answer
intermediate
Why is recursion not efficient for large Fibonacci numbers without optimization?
Because it repeats calculations for the same inputs many times, leading to a lot of unnecessary work and slow performance.
Click to reveal answer
What does the Fibonacci recursive function return for Fibonacci(0)?
A-1
B1
CUndefined
D0
✗ Incorrect
By definition, Fibonacci(0) is 0, which is the base case in recursion.
Which two previous Fibonacci numbers does Fibonacci(n) depend on in recursion?
AFibonacci(n-1) and Fibonacci(n-3)
BFibonacci(n-2) and Fibonacci(n-3)
CFibonacci(n-1) and Fibonacci(n-2)
DFibonacci(n) and Fibonacci(n-1)
✗ Incorrect
The Fibonacci sequence is defined as the sum of the two preceding numbers: Fibonacci(n-1) + Fibonacci(n-2).
What is the main problem with the naive recursive Fibonacci approach?
AIt recalculates the same values multiple times
BIt does not return correct results
CIt uses too much memory
DIt cannot handle negative numbers
✗ Incorrect
The naive recursion repeats calculations for the same Fibonacci numbers, causing inefficiency.
What is the base case condition in Fibonacci recursion?
AIf n > 1
BIf n == 0 or n == 1
CIf n < 0
DIf n == 2
✗ Incorrect
The base cases are when n is 0 or 1, returning 0 or 1 respectively.
What is the output of Fibonacci(4) using recursion?