December 2017
Beginner to intermediate
470 pages
12h 29m
English
If you have deterministic algorithms, every time you provide equal inputs, you should receive equal outputs, and if that's the case and the process to go from inputs to outputs is very time-consuming, you may use memoization or cache layers. The basic idea is that you store some copies of the inputs and outputs, and whenever an input is sent to a function, before computing the output, you check whether or not that specific input's output has been computed before. If it has, send that instead of doing all the work again. This means you should only be computing the output for each input once.
You should try to implement such a layer in the fibonacci_recursive() function we created at the beginning of this chapter ...