CMSC 132:
Object-Oriented Programming II
Recursive Algorithms
Department of Computer Science
University of Maryland, College Park

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
Recursion
Recursion is a strategy for solving problems
A procedure that calls itself
Approach
If ( problem instance is simple / trivial )
Solve it directly
Else
1.
Simplify problem instance into
smaller
instance(s) of the original problem
2.
Solve smaller instance using same algorithm
3.
Combine solution(s) to solve original problem

Recursive Algorithm Format
1.
Base case
Solve small problem directly
2.
Recursive step
Simplify problem into smaller subproblem(s)
Recursively apply algorithm to subproblem(s)
Calculate overall solution

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*