15-112: Fundamentals of Programming and Computer Science
Class Notes: Recursion
-
First, study these examples:
recursion-motivation.py.
-
Then, use the following notes, except that you are not responsible for these parts: iterativeHanoi (in part 5); Expanding the Stack Size and Recursion Limit (callWithLargeStack) (all of part 8); Improving Efficiency with Memoization (all of part 9); quicksort or radixsort (in part 10.7); or More Advanced Recursion Examples (all of part 11).
-
Also, on Macs, use this: def callWithLargeStack(f,*args): return f(*args) # callWithLargeStack broken on Macs
-
Also study these examples (linearSearch and largest):
code,
video1,
video2
-
Finally, use this version of nqueens:
nqueens.py