The purpose of this assignment is to reinforce the concept of recursion in our minds. This recursion assignment does not require coding. However, it does require a detailed walk-thru with a snap-shot of the information on the stack at every call and the state of the data at every return.
The code below is a very simple example of a recursive function to compute the value of factorial (say 5).
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
Your output diagram should look something like the slide 15 of chapter 4 on Recursion.
Please do this assignment carefully, understanding what is going on every step of the way - it should be fun! By drawing the diagrams, depicting what the data looks like at each call, how each return works, will go a long way to understanding how recursion works. It is not all magic!