HomepageTeaching PageResearch PageResources Page

Homework: Recursion

Okay, here we go! Read sections 5.8, 5.9, and 5.10 in the book and do the examples. I strongly recommend drawing out the different stack frames so that it's clear what is happening. I'll be talking about this lots in class, but be sure to try out the recurse() example for yourself.

Modify the recurse function so that it prints out a string before making the recursive call.

def recurse():
    print("monkey")
    recurse()
        

Try it out! Then swap the order of those two lines in the body. What do you expect will happen? What actually happens?