Recursion¶
Steps in writing recursive function¶
- Identify a Base Case
- the base case is the case in which we decide there is no more work for us to do
and it's time to return and stop the recursion process
- Do some amount of work
- Call the function again
- When we call the same function again, it's extremely critical to make sure that we have change the argument(s) in some fashion
- Otherwise, we will enter an infinite loop
- Make sure that whatever returned by the function will eventually get to the Base Case
Recursive Tips: Diagram 04 tab 12
code¶