# Notes 6 - Week 6 Recursion There are two methods for...

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

Week 6: Recursion There are two methods for repetition: iteration and recursion. Recursion may be more efficient and clearer than some iterative versions. Recursion is a form of iteration, so any iterative version would have one extra loop than its recursive version. Definition : A definition is recursive if it is described in terms of itself. Three types of example of recursion will be shown: an English definition, math forms, and most importantly for us, methods. English definition example : A descendant of a person is an offspring or a descendant of an offspring of the person. Question : Is the following definition of rules of group-think by R. D. Laing recursive? Rule A: Don’t Rule A.1: Rule A does not exist. Rule A.2 Do not discuss either the existence or nonexistence of rules A, A.1 and A.2 Answer : Yes since Rule A.2 is in terms of itself. Recursive methods have properties 1. The method is defined in terms of itself (a refresh clause or inductive step) 2. A there is a base case, an escape clause, or anchor: that allows for termination

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

Notes 6 - Week 6 Recursion There are two methods for...

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

View Full Document
Ask a homework question - tutors are online