CSCI 103L Lecture 12: Lecture 12
Document Summary
Midterm thursday: can bring a 8. 5 x 11 cheat sheet. Typed or printed: covers everything we"ve been over before, short answer, code analysis, small hand coding problems. What will the given code print out, etc: practice midterm from last semester online. Recursion: when you de ne an object or a mathematical function in terms of itself. Recursive case: n > 1 = > n*(n-1): tries to take a big problem and break it into smaller versions, recursion double check. Check that you have a base case. Check that your recursion call makes progress to the base case. Recursion vs iteration: if you can easily do a loop go for loop. It is faster: when to use recursion. Usually clean and elegant, easier to read. Sometimes makes writing the code much more simple when iteration would be almost impossible: choose recursion when iteration seems very complex. Ex print ruler problem is easy with recursion and hard with a loop.