This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: factorial ( int n ) { if ( n > 0 ) return n * factorial ( n 1 ); else return 1; } Any iteration can be written recursively, by defining an object in terms of a simple case of itself. Recursion Rules of Recursion: Base cases : You must always have some base cases, which can be solved without recursion. Making progress : For the cases that are to be solved recursively, the recursive call must always be to a case that makes progress toward a base case . Design rule : Assume that all the recursive calls work . Compound interest rule : Never duplicate work by solving the same instance of a problem in separate recursive calls. pay attention to : have some knowledge of C ( C++ ) Programming: including such topics as pointers e recursion and file operation....
View
Full
Document
This note was uploaded on 02/16/2011 for the course CS 135 taught by Professor Yuechen during the Fall '08 term at Zhejiang University.
 Fall '08
 YueChen

Click to edit the document details