DEV Community

Discussion on: From 100% to 0% CPU with memoization

Collapse
 
joaomcteixeira profile image
João M.C. Teixeira • Edited

Great post,
Are you going to expand more on why this is the case?

Btw, going around your implementation, it can be reduced to something like:

# first definitions
i = 50  # fib number
fib = [0, 1, 1]
fiba = fib.append

# application
for i in range(2, i - 1): fiba(fib[-2] + fib[-1])
Enter fullscreen mode Exit fullscreen mode

Both have very similar performances.

Cheers,

Collapse
 
imjoseangel profile image
Jose Angel Munoz

Thank you!! The referred training from Freecodecamp goes deeper on the why and I think is quite cool to follow it. Is it what you mean?

Collapse
 
joaomcteixeira profile image
João M.C. Teixeira

Yeh. I was reading now the original post. I am definitively not an expert in dynamic programming, but definitively I use some those concepts in my daily programming even without knowing it.

Btw, is Fibonacci a good example to teach recursion, anyway?