Recall & Review
beginner Click to reveal answer
What is the base case in a recursive Fibonacci function?
The base case returns the first two Fibonacci numbers directly, usually when n is 0 or 1, to stop further recursion.
beginner Click to reveal answer
Explain how recursion works in calculating Fibonacci numbers.
Recursion calculates Fibonacci by calling itself with smaller inputs (n-1 and n-2) and combining their results until reaching base cases.
intermediate Click to reveal answer
What is the time complexity of the naive recursive Fibonacci algorithm?
The time complexity is exponential, O(2^n), because it recalculates the same Fibonacci numbers multiple times.
beginner Click to reveal answer
Show the first 5 Fibonacci numbers calculated by recursion starting from 0.
The first 5 Fibonacci numbers are: 0, 1, 1, 2, 3.
intermediate Click to reveal answer
Why is memoization helpful in recursive Fibonacci?
Memoization stores results of previous calls to avoid repeated calculations, improving efficiency from exponential to linear time.
What does the Fibonacci recursive function return for input n=0?
✗ Incorrect
By definition, Fibonacci(0) returns 0 as the first number in the sequence.
Which two previous Fibonacci numbers does the recursive function call to calculate Fibonacci(n)?
✗ Incorrect
The recursive formula uses Fibonacci(n-1) + Fibonacci(n-2) to calculate Fibonacci(n).
What is the main drawback of the naive recursive Fibonacci implementation?
✗ Incorrect
Naive recursion recalculates many Fibonacci numbers multiple times, causing exponential time complexity.
Which technique can optimize recursive Fibonacci to run in linear time?
✗ Incorrect
Memoization caches results of recursive calls to avoid repeated work, improving efficiency.
What is the output of Fibonacci(4) using recursion starting with Fibonacci(0)=0?
✗ Incorrect
Fibonacci sequence: 0,1,1,2,3; Fibonacci(4) is 3.
Describe how a recursive function calculates the nth Fibonacci number.
Think about how the function calls itself with smaller numbers until it reaches the simplest cases.
You got /4 concepts.
Explain why naive recursion for Fibonacci is inefficient and how memoization improves it.
Consider how many times the same Fibonacci numbers are calculated without and with memoization.
You got /4 concepts.
