In this chapter we will: introduce recursion as a programming technique, show how recursion can be used to simplify the design of complex algorithms, present several well known recursive algorithms (e.g. quicksort, merge sort, Guaussian elmination), introduce the linked list data structure and recursive implementations for several of its methods, present programs for drawing two types of fractal curves.
Chapter 14 Recursion Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N Kamin, D Mickunas, , E Reingold Chapter Preview In this chapter we will: • introduce recursion as a programming technique • show how recursion can be used to simplify the design of complex algorithms • present several well known recursive algorithms (e.g quicksort, merge sort, Guaussian elmination) • introduce the linked list data structure and recursive implementations for several of its methods • present programs for drawing two types of fractal curves Recursion • Basic problem solving technique is to divide a problem into smaller subproblems • These subproblems may also be divided into smaller subproblems • When the subproblems are small enough to solve directly the process stops • A recursive algorithm is a problem solution that has been expressed in terms of two or more easier to solve subproblems Counting Digits • Recursive definition digits(n) = 1 + digits(n/10) if (–9