C Sc 127B In-Class Activity, 21-March-2007  (14 minutes)

o Form a team of two

o Neatly print both of your full names (first name and last name):

 a. ____________________________     b.   ___________________________

o Choose the scribe (the person writing the answer) as the person with the most siblings.

                                Moksha    Zack    Josh     Will

1.  Write the output generated by these calls to mystery1()

    mystery1(7, 4);
    System.out.println();

    mystery1(1, 2);
    System.out.println();
  
    mystery1(-2, 2);

  ////////////////////////////////////////////
  public void mystery1(int left, int right) {
    if (left <= right) {
      System.out.println(left + " " + right);
      left++;
      right--;
      mystery1(left, right);
    }
    System.out.print("x");
  }

2. Write recursive method printArray() that prints all array elements in a filled array of integers referenced by x.  The method accepts the range of integers to print. Do not use a loop. You may use a helper method.

   int[] x = { 1, 4, 2, 5, 2 };  
   print(x, 0, x.length-1);    // 1 4 2 5 2
   print(x, 1, 3);             // 4 2 5