CSE 131 Module 6: Recursion

Lab


Procedure

Preparation:
  1. Consider the old camp song:
    n bottles of beer on the wall, n bottles of beer; you take one down, pass it around, n-1 bottles of beer on the wall.

    n-1 bottles of beer on the wall, n-1 bottles of beer; you take one down, pass it around, n-2 bottles of beer on the wall.

    and so on down to 0 bottles of beer on the wall.


  2. Here is a simple but interesting recursive function.
       f(x) =    x-10     if x > 100
            = f(f(x+11))  if x <= 100
    

  3. Here is another interesting recursive function:
      g(x,y)  = y+1               if x = 0
              = g(x-1,1)          if x > 0 and y = 0
              = g(x-1, g(x, y-1)) if x > 0 and y > 0
    


  4. Consider the picture below.


Submitting your work (read carefully)



Last modified 11:27:54 CST 30 November 2012
When you done with this lab, you must be cleared by the TA to receive credit.

If you worked in a team using a group– repository:
  • Your work must be committed in that repository for this demo.
  • Each team member must complete this form and have the TA authenticate.
    For example, if there are two of you, then the form must be submitted twice, so that each person's last name and 6 digit ID is captured with the repository name.
  • The repository name must be included on each of the submissions.

group– Enter the name of your group repository here
Last name 6-digit ID
1

TA: Password: