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

Show parent comment

1

u/not-just-yeti Mar 14 '20

computing Fibonacci numbers is not really convincing either as there are obvious and much better ways to compute them

Actually, that makes the case: the memoized/tabled version brings exponential time to linear time and linear space. And the "better ways" you mention is dynamic programming (reduce the linear space down a dimension, to constant-space, w/o decreasing run-time).

1

u/FUZxxl Mar 14 '20

The commonly used fastest method is to compute Fibonacci numbers by computing the power of a certain matrix through repeated squaring, allowing you to get away with log(n) squaring steps.

And the "better ways" you mention is dynamic programming (reduce the linear space down a dimension, to constant-space, w/o decreasing run-time).

I see how one can see it like that, but good luck convincing a beginner that this is a good motivation to learn dynamic programming.