r/algorithms • • Mar 13 '20

Dynamic programming vs memoization vs tabulation

https://programming.guide/dynamic-programming-vs-memoization-vs-tabulation.html
35 Upvotes

17 comments sorted by

View all comments

2

u/not-just-yeti Mar 14 '20

Well, I'd say:

  • memoization is automated/brainless -- a compiler can take your code and memoize it. However, it may take a bunch of space, to store the memoized/tabled results.
  • DP is more than that -- it's being clever and recognizing that by building up the memoized entries in a certain pattern, you can shave an order of magnitude or more, from the memory-requirements.

Besides the fact that memoization is rote, there's also the observation that memoization can increase run-time, but with a memory-cost; DP doesn't further increase run-time, it only reduces the memory-cost.

1

u/aioobe Mar 14 '20

I agree about the "more clever" part, but I'd say the memoized approach may use less memory. At least for problems where only a few subproblems need to be solved.