Compsci 101, Fall 2014, Lab 11

There are two part to this lab: the first is discussing an APT for this week. The second part is practicing with recursion.

The lab

In this lab you will:

You will need to snarf the APT.

Getting Credit for Lab 11

To get credit for this lab, you will need to enter your names and netids, and the answers to several questions on an online form.

Complete this form for credit for lab 11

(the same questions are accessible here as well).

Part 1: Thesaurus APT

Consider the Thesaurus APT.

Use the questions on the online form to drive your understanding and solving of the problem.

Part 2a : Recursion

First discuss the following mystery function and calls to it. How many recursive calls are there for each call (the original call is not a recursive call)? What is the return value in each case?

def mystery(x, y):
    if x <= y:
        return 1
    return 2 + mystery(x-1, y+1)


print mystery(5,5)
print mystery(7,4)
print mystery(10,3)

Answer these questions on the online form.

Part 2b : Recursion

Now you will rework three older APTs by rewriting them to solve them with recursion - Acronym, CountAppearances, and Bagels.

Since you already have them done, you could comment out the code you have and put in new code that uses recursion.

See the questions on the online form to guide you in solving them with recursion.

Submit

When you are finished, be sure to submit the google form for this lab.

Also, remember that you have to turn in your APT for Thesaurus through ambient for APT credit. The APTs you redid with recursion for Part 2 are only turned in on the lab form.