{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

16RecursiveAlgorithms

16RecursiveAlgorithms - CMSC 132 Object-Oriented...

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

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

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

View Full Document
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 blurred sections. Sign up to view the full version.

View Full Document