Dynamic Programming, Recursion, Python, Coding Tutorial, Python Programming.
have defined a dictionary globally, so it is available to all the fib() calls (line 1). Next, after the base cases, we check whether this number has already been evaluated. If it was, its memoized value is returned (lines 8-9). Otherwise, we need to evaluate this result, and this is where we make