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!

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.