CSC148H5 Lecture 4: Lecture 4
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.