Could anybody explain how it is that the computer ever gets to walkTree(tree['right'])
? I believe that the function keeps calling itself until None
and then recursively pops off all of the "left" stacks and printing them, but when the function calls walkTree(tree['right'])
, what is the computer doing when it passes by walkTree(tree['left'])
again?
def walkTree(tree):
if tree == None:
return None
walkTree(tree['left']
print(tree['data'])
walkTree(tree['right'])