COMPSCI 61A Lecture Notes - Lecture 4: Dwindle Distribution
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
An the environment diagram is used to keep track of all variable and functions. X=l def fun ( c i an global variables def are stored global. X=2 def fun global y=o func parent x u return. 2 assignment: evaluate statement y lo the return e the side of b) write value in the current variable name frame expression on right and the expression "s, defining create a, [ parent a. = global indicates where the function was first defined: most function frames will have a return value. It can be broken is any function which calls itself into. Sections: base case the simplest version of problem, recursive can : where the function. Calls itself on a smaller input c) value. Mechanism : the final the recursive call and of return value is typically a one more value def factorial factorial. Recursive inpmrnnf return case num else ( numh factorial. Err or if return else return some valuetrecursivecan.