F = lambda x : 1 if x == 0 else x*F(x-1) print F(3) F(3) waiting for 3*F(2)
4
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
-
Upload
daquan-kirkland -
Category
Documents
-
view
25 -
download
0
description
Factorial Recursion Runtime Stack. 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. R. 4. RR. RL. 2. 5. RLL. RLR. RRL. RRR. 1. 3. RLLL. RLLR. RLRR. RLRL. - PowerPoint PPT Presentation
Transcript of F = lambda x : 1 if x == 0 else x*F(x-1) print F(3) F(3) waiting for 3*F(2)
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()