|
|
|
|
|
by Immortal333
2177 days ago
|
|
After, reading your comment. I cross checked result and found out that 3 is most optimal size. I even ran fib(40) on it. with size 2, There are many misses but after 3 and on wards misses are constant(if fib(40), then misses are only 40 which emulates DP approach of O(N)). Why 3 is optimal, because of how recursion and LRU work. I wish i can explain it using animation. You can play with it. https://repl.it/repls/NocturnalIroncladBytecode#main.py |
|
If this theory is correct, every recursive function f(n) requiring access to f(n-x) should have x+1 as maximum usefull cache size.