Advanced Placement Computer Science


Course Overview
Course Policies
Computer Science AP
   Syllabus 
   Class Schedule
   Homework
   Labs
   Projects
   Extra Credit
   Study Material
   Grades
Computer Science 2 AP

Get Software
Useful Resources
Teacher Information


Computer Science AP


Announcements!

5/3/04
  • !)$@&*)*&%)
Apparently there was another change on this year's CS1AP that I was not aware of.  For the first time ever, they swapped Quick Sort for Merge Sort on the CS A AP.  (CS2 still needs to know both)

Thankfully merge sort is easier, but man, this is the first I've ever seen of this.  Quick Sort has  ALWAYS been an A topic.

Mergesort is just splitting the array into halves and sorting the halves and then recombining the halves, "merging" them in order. If you keep on splitting the arrays until you end up with arrays of size 2, you can sort them each in a single step, and then recombining them will take very little time as each subarray is sorted.  The algorithm is actually simpler than Quicksort. It is USUALLY recursive. The notes for this (and it is online!) http://home.earthlink.net/~casaburi.../mergesort.html

The consequences of this are it ALWAYS has an O(N) of N*LOG(N) (Quicksort varies depending on luck of what pivot is selected), and it is somewhat less efficient in terms of memory usage since it has to create the half-arrays all the time.

No, I'm not kidding.  And yes, I am in shock about this.

Also anyone looking for coverage of any Computer Terms/etc they will cover, look at the notes for Chapter "0"..  It's the first link under lecture notes.

10/5/03
  • Instructions for how to get reset working correctly in the Vic class.  (taken from the class forum)
Ok, there is a lot of misinformation out there on reset. Some of it is caused by small mistakes in the book, some of them caused by myself.

reset () is a static method built into the Vic class that takes in an array of Strings as its arguments. What are those? They are a bunch of pieces of text. We haven't covered how to handle those yet, though we will. Right now you only have handy access to a single type of array of strings, namely the command-line parameters signified by the String[] args in your main method.

If you ever see a reset() with no arguments, either the book is assuming another copy of reset exists, or it is a mistake.

The only method (pun not intended) to specify how many slots are available and which are populated is to use that args variable in main. For instance, given the following code in a class:

public static void main(String[] args) {
Vic myvic;
myvic = new Vic();
Vic.reset(args);
}

you cannot (easily) directly specify the value for reset, but you can pass that information in two ways:

if you are compiling this for a command line (let's assume the java file is called myfile.java) you'd type the following:
javac myfile.java Vic.java
java myfile 1001

that creates a sequence with 4 slots, with the 1st and the 4th slot filled with a cd. To change it to be 5 slots, with each one filled, you would type the following:
java myfile 11111

If you are doing this through bluej, it is much the same except you feed the information for args a little bit differently. When you right click on the class and pick out void main it will ask you what information to feed it.
You type it in in the following fashion: to have 5 slots, each one filled, type in {"11111"} into the box provided then hit ok
To have 4 slots, each one empty, type in {"0000"} and for 5 slots, only the 2nd on filled type {"01000"} and so forth.


9/15/03
  • Instructions on how to get turtle compiling
For BlueJ to get programs using Turtle running, add Turtle.java and Turtlet.java into your project. (click on edit->add class from file)  Once there you can compile the files and create a new class that uses the Turtle objects. 


For command-line compiling, you need to copy Turtle.java and Turtlet.java into the directory that the .java file you want to compile is.  Assuming your .java file is named MyClass.java you would type the following at the command prompt.

javac Turtlet.java Turtle.java MyClass.java

replace MyClass with whatever your .java file is actually named (remember, it will also be named exactly the same as the name of your class, and also remember that capitilization matters!)

once you have done that you can run your program as follows

java MyClass

Again, replace MyClass with whatever the correct name is, and this assumes you have a method defined within the class called main declared as a public static method with arguments of String[] args
(the declaration would start with public static void main(String[] args) {    )

Note:  at this point, it is probably much easier to deal with BlueJ than the command-line.

9/10/03
9/3/03 
  • We have a room for lectures at S-52.  We meet there tomorrow (Thursday)
      


last updated on 5/3/04
Copyright (C) 2004 Jim Casaburi