12b-recursion

# 12b-recursion - CSE143 Lecture12(B Recursion...

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

CSE 143 Lecture 12 (B) Recursion reading: 12.1 - 12.2 slides created by Marty Stepp http://www.cs.washington.edu/143/

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

View Full Document
2 Recursion recursion : The definition of an operation in terms of itself. Solving a problem using recursion depends on solving smaller occurrences of the same problem. recursive programming : Writing methods that call themselves  to solve problems recursively. An equally powerful substitute for  iteration  (loops) Particularly well-suited to solving certain types of problems
3 Why learn recursion? "cultural experience" - A different way of thinking of problems Can solve some kinds of problems better than iteration Leads to elegant, simplistic, short code (when used well) Many programming languages ("functional" languages such as  Scheme, ML, and Haskell) use recursion exclusively  (no loops) A key component of the rest of our assignments in CSE 143

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

View Full Document
4 Exercise (To a student in the front row) How many students total are directly behind you in your  "column" of the classroom? You have poor vision, so you can see only the people right next to you. So you can't just look back and count. But you are allowed to ask questions of the person next to you. How can we solve this problem? ( recursively  )
5 The idea Recursion is all about breaking a big problem into smaller  occurrences of that same problem.

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 / 18

12b-recursion - CSE143 Lecture12(B Recursion...

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

View Full Document
Ask a homework question - tutors are online