This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS 134 Tutorial 7: Recursion and Binary Trees CS 134 Tutors Winter 2008 1 Recursive Definitions In order to solve large problems, it is sometimes easier to break the problems down into smaller, more man- ageable problems of the same type. This idea of “divide and conquer” is often used in computer science. We can create a recursive definition of a function of n in two steps: Base Case(s) Define the function for values of n (usually small) for which you can write down the answer directly. You need at least one base case. Recursive Case(s) For all other values of n in the domain of the function, define the function in terms of a combination of smaller instances of the same function. You need at least one recursive case, and recursive cases must be able to degenerate into a base case. When defining certain words or expressions recursively, we can use the above approach if we have a function. We can create a function that is true when the argument meets the definition and false otherwise....
View Full Document
This note was uploaded on 01/25/2010 for the course CS CS134 taught by Professor Cl during the Fall '07 term at Waterloo.
- Fall '07