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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2012 for the course CS 111C taught by Professor Metzler during the Spring '11 term at City College of San Francisco.

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 Right Arrow Icon
Ask a homework question - tutors are online