CS2
Recursion
7
Components of recursive definition
n• Every valid recursive method definition needs two parts – the base case and the recursive part
n• The base case gives the value that the method should return for some specified parameters
n– Usually the base case represents some sort of “trivial” case, such as a zero parameter or an empty list etc.
n• The recursive part expresses the value to be returned in terms of another call to the same method, but with different parameters
n– To work correctly, the “different parameters” must be closer to the base case (in some sense)