I'm learning about recursion and I wrote this (inefficient) n'th Fibonacci number calculator:
def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
I know that in recursion, you can draw so called 'recursion trees'. When I made this simple binary generator:
def binary(length, outstr=""):
if len(outstr) == length:
print(outstr)
else:
for i in ["0", "1"]:
binary(length, outstr + i)
I could figure out what this tree looks like:
But I cannot figure out the tree of the Fibonacci function! What would that tree look like?
Thanks in advance,