Calls with and without memo
Warm-up · Trace the algorithm · about 5 min
Count the calls fib(5) makes, first by the plain rule and then with a memo. Answer each question before the trace plays. Every call counts, base cases and memo hits included.
Example 1
Input:
{"n":5}
Output:
5
Constraints
- The trace uses fib(5) with a memo.
- Answer with whole numbers.
Learn the idea first: Overlapping subproblems and memoization, a visual lesson.
More Overlapping subproblems and memoization problems
- Memoized Fibonacci Warm-up
- Which calls hit the cache Standard
- Climbing stairs with a memo Standard
- Fewest steps to one Standard
- Memoized grid paths Challenge