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 09:53:05 CDT 16 May 2016
When you done with this lab, you must be cleared by the TA to receive credit.

This demo box is for lab 6
Last name WUSTL Key Propagate?
(or your numeric ID) Do not propagate
e.g. Smith j.smith
1 Copy from 1 to all others
2 Copy from 2 to all others

TA: Password: