- Review recursion by looking at examples.
- Show how recursion is implemented using a run-timestack
Recursion
We have seen several examples of functions that call otherfunctions. In this lab, we look at functions that call themselves,known as recursion. A function is said to be defined recursively ifits definition consists of two parts:
- An anchor or base case, in which the value of the function isspecified for one or more values of the parameter(s).
- An inductive or recursive case, in which the function’s valuefor the current value of the parameter(s) is defined in terms ofpreviously defined function values and/or parameter values.
Tasks:
- Write a nonrecursive method that returns
OROR