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

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

View Full Document Right Arrow Icon
CSE 143 Lecture 12 (B) Recursion reading: 12.1 - 12.2 slides created by Marty Stepp http://www.cs.washington.edu/143/
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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  )
Background image of page 4
5 The idea Recursion is all about breaking a big problem into smaller  occurrences of that same problem.
Background image of page 5

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

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

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