go to previous page   go to home page   go to next page

Answer:

A base case of a recursive definition is a case that has an immediate solution.

factorial( 0 ) = 1 <-- base case
factorial( N ) = N * factorial( N-1 )

Static View of Recursion

In the "static view" of recursion, you translate a math-like definition into the Java method definition. You don't think much about what happens when the method runs. Here is the math-like definition of factorial:


factorial( 0 ) = 1
factorial( N ) = N * factorial( N-1 )

And here its translation into Java:

int factorial( int N )
{
  if (  )
  
    return 1;
    
  else
  
    return  *  ;
}

Practice thinking statically. Finish the translation.


QUESTION 3:

Fill in the blanks.