Recursion1.9 - CSE 2011 Prof. J. Elder - 47 - The...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated 12-01-24 10:12 AM CSE 2011 Prof. J. Elder - 46 - The “Curse” in Recursion: Errors to Avoid // recursive factorial function public static int recursiveFactorial( int n) { if ( n == 0 ) return recursiveFactorial(n) ; // base case else return n * recursiveFactorial ( n - 1 ); // recursive case } The base condition must not involve more recursion!
Background image of page 1

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

View Full DocumentRight Arrow Icon
Last Updated 12-01-24 10:12 AM
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 2011 Prof. J. Elder - 47 - The “Curse” in Recursion: Errors to Avoid // recursive factorial function public static int recursiveFactorial( int n) { if ( n == ) return 1 ; // base case else return ( n – 1) * recursiveFactorial ( n ); // recursive case } • The input must be converging toward the base condition!...
View Full Document

This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Page1 / 2

Recursion1.9 - CSE 2011 Prof. J. Elder - 47 - The...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online