COMPSCI 61A Lecture 7: CS 61A LEC 07
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
Due the monday after the midterm (september 19th) Your score is the number of entries against which you win more than 50% of the time. The top 3 entries will receive a small amount of extra credit. The value of a recursive call is not calculated until you return the base case. Each call to a function within recursion creates a new frame with the same parent. Until the return value appears, that call has not completed. Any statement can appear before or after the recursive call. If two implementations are equally clear, then the short is usually better. When learning to write recursive functions, put the base cases first. Tree-shaped processes arise whenever executing the body of a recursive function makes more than one call to that function. Fibonacci numbers def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-2) + fib(n-1)