Intro to Recursion
Consider problems/tasks that are parametrized by an integer
–
Computing the factorial of a number
n
–
Computing the eigenvalues of an
nbyn
matrix
–
Computing the determinant of an
nbyn
matrix
Assume that
–
For any
k
, the solution for the case
n=k+1
can be written very clearly
in terms of the solutio for the
n=k
case, and…
–
Solution for
n=0
case is “obvious”
Then, a recursive
strategy can be used to solve the problem
for any value of
n.
A program is recursive
if it calls itself.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Intro to Recursion
Assume that
–
For any
k
, the solution for the case
n=k+1
can be written very clearly
in terms of the solution for the
n=k
case, and…
–
Solution for
n=0
case is “obvious”
Then, a recursive
strategy can be used to solve the problem
for any value of n.
1.
Complex (level 3) problem, “I don’t think I know how to solve this”
2.
Reduce problem “1level” through a clever step
1.
Complex (level 2) problem, “I don’t think I know how to solve this”
2.
Reduce problem “1level” through a clever step
1.
Complex (level 1) problem, “I don’t think I know how to solve this”
2.
Reduce problem “1level” through a clever step
1.
Simple (level 0) problem, “I know how to solve this”
2.
Solve level0 problem
3.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '08
 Patzek
 Recursion, Det, function instance

Click to edit the document details