Recall & Review
beginner Click to reveal answer
What is the base case in a recursive Fibonacci function?
The base cases are when n is 0 or 1. For n=0, Fibonacci returns 0; for n=1, it returns 1. These stop the recursion.
beginner Click to reveal answer
Explain how recursion works in calculating Fibonacci numbers.
The function calls itself twice for n-1 and n-2, then adds the results. This repeats until base cases are reached.
intermediate Click to reveal answer
What is the time complexity of the naive recursive Fibonacci algorithm?
It is exponential, specifically O(2^n), because it recalculates the same values many times.
beginner Click to reveal answer
Show the recursive formula used in Fibonacci sequence.
F(n) = F(n-1) + F(n-2) with base cases F(0) = 0 and F(1) = 1.
intermediate Click to reveal answer
Why is recursion not efficient for large Fibonacci numbers without optimization?
Because it repeats calculations many times, leading to a lot of unnecessary work and slow performance.
What does the Fibonacci recursive function return when n = 0?
✗ Incorrect
By definition, Fibonacci(0) = 0 as the base case.
Which two previous Fibonacci numbers does the recursive function add to get F(n)?
✗ Incorrect
The recursive formula is F(n) = F(n-1) + F(n-2).
What is the main problem with the naive recursive Fibonacci approach?
✗ Incorrect
Naive recursion repeats calculations, causing exponential time complexity.
What is the base case for Fibonacci recursion when n = 1?
✗ Incorrect
Fibonacci(1) = 1 is the base case to stop recursion.
Which of these is a better approach to optimize Fibonacci calculation?
✗ Incorrect
Both iterative loops and memoization improve efficiency over naive recursion.
Describe how a recursive function calculates the Fibonacci number for n=4.
Think about the tree of calls and how results combine.
You got /4 concepts.
Explain why the naive recursive Fibonacci function has exponential time complexity.
Consider how many times the function calls itself.
You got /4 concepts.
