COMPSCI 61A Lecture Notes - Lecture 4: Iterated Function, Luhn Algorithm
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
You may bring 1 two-sided page of hand-written notes that you create yourself. Practice exam will be posted later this week. Additional topic lectures wednesday 5-6:30pm for an additional unit. A recursive function is a function whos body calls itself either directly or indirectly. The def statement header is similar to other functions. Each time you call a function in recursion you create a new frame with the same parent as the first function call. Multiple frames keep track of the different arguments in each call. What each variable evaluates to depends upon which is the current environment. Each call to the function solves a simpler problem than the last (the index decreases) Iteration is a special case of recursion (while and loops vs recursion) To test verify if a recursive function is implemented correctly. Verify that (n) is correct assuming that (n-1) is correct. Occurs when two functions mutually call each other.