3 ms·
In the knapsack example they say... > "No global variables should be modifed in the function" Am I wrong or does the author immediately go on to modify the gl
by zerocool2750 8y ago
In the knapsack example they say...
> "No global variables should be modifed in the function"
Am I wrong or does the author immediately go on to modify the global variable 'dp'
p.s. @author typo in that sentence 'modifed'
- Aditya_Ramesh 8y agoThanks for pointing out the typo! I'll fix that right away. And in regards to the "global variable", my variable 'dp' is my cache array. It's where I'm storing my precomputed results. If I don't modify it, it's not DP anymore, it's plain recursion. :) I guess I should've mentioned that the actual memoization table is an exception. Anyway, thanks for reading my article! :)
- zerocool2750 8y agoTotally makes sense I just think it's slightly confusing in that context. Anyway, awesome article I enjoyed the read!
- Aditya_Ramesh 8y agoThank you! I'll make sure to go over some non-classical problems in my next article on DP to add more value :)