P3: Recursion

Due Monday, July 6, 12:00 PM via Checkin
Late deadline, July 6, 11:59 PM
100 points

1. Objective

The objective of this assignment is to practice recursion. You will not get any points if you use loops (while, for, or do) in this program.


2. Tasks

In a file called P3.java, write a Java class called P3, which contains the following methods.


3. General Information

None of the methods above should be declared static. In fact, compilation of your program will fail if the method signatures in your program are different than above. Do not hardcode any parameters into your methods. Test your program with test data in addition to what is already provided in the assignment.

Keep in mind that we will not test your main method -- the methods you implement will be tested directly. However, you should use your main to test the methods that you write. A barebones main can include something like:

    public static void main(String [] args) {
        P3 p = new P3();
        System.out.println("duplicateEachCharacter(Ja~a) = " + p.duplicateEachCharacter("Ja~a"));
        int[] numbers = new int[] {5, 6, 7, 2, 3, 1};
        System.out.print("computeCumulativeSums(numbers) = ");
        System.out.println(Arrays.toString(p.computeCumulativeSums(numbers)));
        int[][] table = new int[][] { {5, 2, 8, 5, 61}, {3, 9, 6}, {10, 42, 53, 45}};
        System.out.println(p.searchTable(table, 45));
        System.out.println(p.searchTable(table, 100));
}

4. Submission

Submit the P3.java file via the online checkin system. This system performs preliminary testing of your program using the examples above. Final grading will be performed on a different set of data.