{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Recursion+posted

Recursion+posted - Intro to Recursion Consider...

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

Intro to Recursion Consider problems/tasks that are parametrized by an integer Computing the factorial of a number n Computing the eigenvalues of an n-by-n matrix Computing the determinant of an n-by-n 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 “1-level” through a clever step 1. Complex (level 2) problem, “I don’t think I know how to solve this” 2. Reduce problem “1-level” through a clever step 1. Complex (level 1) problem, “I don’t think I know how to solve this” 2. Reduce problem “1-level” through a clever step 1. Simple (level 0) problem, “I know how to solve this” 2. Solve level-0 problem 3.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}