Memoization
Learn how to tackle the inefficiency of repeated function calls introduced by recursion.
We'll cover the following...
Use a dictionary
The basic problem in the Fibonacci example is that we are calling fibonacci
multiple times, with the same argument. So, each time we are calculating the same value all over again.
Now, we know that fibonacci
is a pure function. It has no side effects, and every time you call it with a particular value, you will always get the same result. ...
Access this course and 1400+ top-rated courses and projects.