F = lambda x : 1 if x == 0 else x*F(x-1)print F(3)
F(3) waiting for 3*F(2)F(2) waiting for 2*F(1)F(1) waiting for 1*F(0)F(0) returns 1
Factorial Recursion Runtime Stack
44
55
3311
22
R
RR
RRRRRL
RLRRRLRLRLLRRLLL
RLRRLL
RL
# For the book BST code, do the following to get this tree:numbers = [4,2,1,3,5]intTree = BinaryTree()for e in numbers: intTree.insert(e)
# The next pages show the runtime stack for:print intTree.inorder()# andprint intTree.postorder()
Top Related