Recursion Practice Problems


  1. Trace the following method being invoked via doStuff(3); to determine the final result.
    public static int doStuff(int n) {
       if (n<1) return n;
       return 2*n + doStuff(n-1);
    } 

  2. Solve the example at codingbat.com/prob/p183649

  3. Solve the example at codingbat.com/prob/p183394

  4. Write a recursive method with the following signature that can be used to get the largest value in an array.
         public static int findMax(int[] list, int front)

  5. Write a recursive method that will print the contents of an ArrayList of Float values out backwards.