YCP Logo Problem Set 8

Due: Friday, Nov 21st by 11:59 PM

Do the following problems from Weiss:

  • 6.8
  • 6.18

Additional problems:

A. Use proof by induction to prove that, for all n ≥ 1

1 + 3 + 5 + ... + (2n - 1) = n2

B. Write a recursive method called reverseArray that reverses the elements of a given array of int values. Use a helper method if necessary.

Example test:

int[] arr = new int[]{ 8, 26, 25, 20, 36, 24, 43, 13 };

reverseArray(arr);

assertEquals(13, arr[0]);
assertEquals(43, arr[1]);
assertEquals(24, arr[2]);
assertEquals(36, arr[3]);
assertEquals(20, arr[4]);
assertEquals(25, arr[5]);
assertEquals(26, arr[6]);
assertEquals(8, arr[7]);

Save your solutions in a single file, in plain text, MS Word, OpenOffice, or PDF format. Upload the file containing your solutions to the Marmoset server as project hw8. The server URL is

https://camel.ycp.edu:8443/