Practice question · Multiple choice
Naive recursive Fibonacci takes exponential time; adding memoisation makes it linear. Why does storing results change the growth class so dramatically?
Hints
- Draw the call tree for F(5). How many times does F(2) appear?
- Ask how many DISTINCT subproblems exist for F(n).
Show the answer
B. Because the naive version recomputes the same subproblems exponentially.
Why
Draw the call tree and the waste is visible: about 2ⁿ nodes containing only n distinct values. Memoisation removes duplication rather than speeding anything up, so the work becomes proportional to the number of distinct subproblems. That identifies when the technique applies, overlapping subproblems, plus optimal substructure. Merge sort's halves are all distinct, so there is nothing to reuse.
Practise Dynamic Programming Intuition
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Dynamic Programming Intuition
- Match each dynamic programming concept to its meaning.
- Memoisation and tabulation both solve the same dynamic programming problems. When does the choice actually…
- Select every problem the lesson names as a classic dynamic programming problem.
- Sort each description by which style of dynamic programming it belongs to.