suppose that I have a fibonacci function like this using recursion
def fib(n):
if n==1 or n==2: return 1
else: return fib(n-1)+fib(n-2)
when it comes to fib(n-1)+fib(n-2), I wonder which function will be computed first fib(n-1) or fib(n-2) or they both are computed at the same time.
and if it's fib(5)
Does the process go like (a,b,d,h,i,e,c,f,g)
actually I just learn about dynamic programming and I just want to know when the memo takes the value while the function's executed.
please let me know if this question makes you confuse because my english isn't good, and i'll try explain more.
def fib(n):
if n==1 or n==2: return 1
else: return fib(n-1)+fib(n-2)
when it comes to fib(n-1)+fib(n-2), I wonder which function will be computed first fib(n-1) or fib(n-2) or they both are computed at the same time.
and if it's fib(5)
Does the process go like (a,b,d,h,i,e,c,f,g)
actually I just learn about dynamic programming and I just want to know when the memo takes the value while the function's executed.
please let me know if this question makes you confuse because my english isn't good, and i'll try explain more.
Last edited: