Name: ____________________________________________________ Alpha: _____________ Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read the lecture notes from today. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [12pts] Consider the following recursive function:
    
    void toy(int n) 
    {
      if (n != 0) 
      { 
        cout << "A"; 
        toy(n - 1); 
        cout << "C"
      }
      else
      {
        cout << "B"; 
      }
    }
    
    1. [2pt] Circle the base case with label B.
    2. [2pt] Circle the recursive case with label R.
    3. [4pts] What output would the call toy(3) lead to?
      
      
      
    4. [4pts] What values for x would cause an infinite recursion if the call toy(x) were made?
      
      
      
  3. [8pts] Consider the following function sum. The function sums integers from start and end. For example, sum(2,5) will return 14, because we have 2+3+4+5 = 14. Fill out the blank.
    
    int sum(int start, int end)
    {
      if( start > end ) 
        return -1;  // error!
    
      if(                )
        return end;
      else
        return start +                           ;
    }
    

Bring to class