CSC148H5 Lecture 4: Lecture 4

42 views1 pages
1 Apr 2018
School
Course

Document Summary

Literally, it means defining something in terms of itself in other words, recursion is something that has a recursive structure (a structure that is defined in terms of itself). Problem: draw painting of size x describe the procedure as a human. 15 draw painting of size x: draw woman with size x draw frame with size x draw painting with size 0. 5x put woman, frame and the small painting at the right positions. Improving the solution so we should stop drawing at some point. When the size is so small that we can just ignore the procedure and do something simple. This we call a base case: a case so small/simple that we can directly solve without recursing into the next level. A working recursive solution must have a base case. def solve(problem): A general tip about tracing when you try to construct the solution code of a problem, don"t do the tracing with multiple levels of recursive calls.

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

Related Documents