AP CS Assignments
Assignments by week:
Fall Term:
Winter Term:
Spring Term:
Monday, October 22
Description
Multiple-Choice Test
Homework
  • Now that we've learned most of Java's syntax, you may find the Princeton Java Programming Cheat Sheet useful (feel free to bookmark it). Skip anything that says "Our XXX Library" (those are specific to Princeton).
  • Read the Rhoads/Gearen excerpt I've sent to you.
Tuesday, October 23
Description
Test Review
Homework
Thursday, October 25
Description
Why Algorithms and Data Structures?
Homework
  • Read the Java Tutorial on Enum Types.
  • Create an Enum called Student with the names of the students in one of your classes (not this one) as its values. Each enum value should have a username (e.g., "13abc"), gender (e.g., "Male"), and boarding (e.g., "Boarder" or "Day") attribute. Create a program that iterates over all possible types of the enum and prints their name and attributes.
  • Read the Java Tutorial on Generics.
  • Read about the Comparable interface, specifically its compareTo() method.
Friday, October 26
Description
Enums and Generics
Homework
  1. Read Searching in an Array in OpenDSA.
  2. Complete the following methods (without copying and pasting from anywhere; see if you can do it after reading about it!):
    1. /** * Iterative Binary Search * * Searches through the given sorted array for the given target value. * If found, it returns the index of the target value. * If the value does not exist in the array, -1 is returned. * * @param a An array of integers sorted in ascending order * @param t The target value to search for * * Precondition: The array is sorted in ascending order * Postcondition: Returns the index of t in the array, or -1 if not found */ public int ibs(int[] a, int t) {
    2. /** * Recursive Binary Search * * Searches through the given sorted array for the given target value. * If found, it returns the index of the target value. * If the value does not exist in the array, -1 is returned. * The search only takes place between the indices "min" (inclusive) * and "max" (exclusive). The initial recursive call would therefore be * rbs(a, t, 0, a.length); * * NO LOOPS ARE ALLOWED IN THIS METHOD (only recursion) * * NOTE THAT a[max] IS NOT PART OF THE SEARCH; you only search from * min to max-1 * * @param a An array of integers sorted in ascending order * @param t The target value to search for * @param min The smallest index to search from (inclusive) * @param max The largest index to search to (exclusive) * * Precondition: The array is sorted in ascending order, * 0 <= min <= a.length, * 0 <= max <= a.length, * Postcondition: Returns the index of t in the array, or -1 if not found */ public int rbs(int[] a, int t, int min, int max) {