CSCI 103L Lecture 12: Lecture 12

29 views2 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers