lecture_22

lecture_22 - Lecture 22 Comp 116 Mar 16th, 2009 Objectives...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style 10/6/09 Lecture 22 Comp 116 Mar 16th, 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
10/6/09 Objectives Recursion Examples on Sorting & searching.
Background image of page 2
10/6/09 Recursion
Background image of page 3

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

View Full DocumentRight Arrow Icon
10/6/09 Definition Definition of recursion Math: A set or function that refers back to itself Examples A(0) = 1, A(n+1) = 2 + A(n) A(0) = 2, A(1) = 3, A(n+1) = A(n) * A(n-1)
Background image of page 4
10/6/09 Definition Definition of recursion Math: A set or function that refers back to itself Computer science: a function that calls itself Example function a = A(n) if (n == 0) a = 1; else
Background image of page 5

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

View Full DocumentRight Arrow Icon
10/6/09 Recursion – types A function can call itself self recursion A function calls another function which calls itself mutual recursion
Background image of page 6
10/6/09 Requirements Stopping condition(s) Reduction in problem size (need not decrease monotonically) Managing the variables
Background image of page 7

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

View Full DocumentRight Arrow Icon
Order of operations Do work, then recurse can be easily replaced with loops Recurse, then do work. cannot be easily replaced by loops
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2009 for the course COMP 116 taught by Professor Stotts during the Spring '08 term at UNC.

Page1 / 29

lecture_22 - Lecture 22 Comp 116 Mar 16th, 2009 Objectives...

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

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