Tutorial 7

Tutorial 7 - CS 134 Tutorial 7: Recursion and Binary Trees...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 5

Tutorial 7 - CS 134 Tutorial 7: Recursion and Binary Trees...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online