AP Computer Science Resources

Below are some links to resources that pertain to topics discussed in the AP Computer Science class for C++.

General AP Information
College Board: http://www.collegeboard.com/ap/students/compsci/
The AP Classes (apstring, apvector, etc. - dont' forget to add the #include "ap???.cpp" line before the #endif line to each header file to use in Turbo C++!): http://www.collegeboard.com/ap/students/compsci/classes.html
Bjarne Stroustrup's C++ Page at AT&T Research: http://www.research.att.com/~bs/C++.html
CPlusPlus.com (C++ Resources and documents, etc.): http://www.cplusplus.com/
Owen Astrachan's Web Page at Duke CS: http://www.cs.duke.edu/~ola/ap.html
All about the Case Study: http://max.cs.kzoo.edu/AP/Fish/index.html
Ask Alice (C++ Information and a PDF textbook): http://iisweb.cis.drexel.edu/elearning/screen/pages/Alice.html

6/9/03

Here's a rundown of things you should know before my final quiz on Tuesday. You should e-mail me with any questions.

  • Understand the code that creates a Socket (and Server Socket) and passes data back and forth. Do you know how to create a class that constructs each of these in main()? Do you know how to create a reader and writer for each? Then, could you print "Hello World" from the socket, and display it on the screen of the server socket? You should, as we went over all of these components in (boarderline overkill) detail.
  • Know what javadoc does. I'm not going to ask how exactly to use it (since we haven't), but you should remember a little about what it does and how it reads your source code.
  • Know what javah does and why it's potentially useful. Hint - Remember the Java Native Interface.
  • In a sentence, what is a thread? In another sentence, why do you think we should bother with them?
  • Know a tiny bit from the articles I had you read. While I won't ask particulars about the contents of each article, it would be nice if you could relate some of the information. For example, what does it basically mean to be a Java Bean (in a sentence -- hint, you should know this without even having read the article!), and be able to tell me if Java is a compiled or interpreted language (hints - bytecode, etc.).

So, think about the things we discussed. You should be able to think about the above things at least at an introductory level. I won't ask surprising questions on the Java architecture type things (bullet points 2 and down). Just think about questions I asked (or you asked) in class as we went along. You should be able to write some code for me per bullet number 1 without any problem at all. I expect the whole thing to last about 15-20 minutes max, just to make sure you're prepared to write some code on-the-fly with me on Tuesday.

Good luck!

4/10/03 A question came up about BigO complexity of the classic sorting algorithms. Please refer to this page for a detailed explanation of each one. It would be to your advantage to understand the complexity of each one for the exam; consequently, we'll be discussing them soon.
3/21/03

Regrettably, I was not able to come in this week as I am preparing for workshops next week. I will also be out next week. However, I will probably have access to the internet so please feel free to contact me with any questions or issues! When I return, we'll go over free response questions and sample AP exams.

If you haven't sent me a Fraction program yet with outstream, please do so!

3/11/03

I have posted a mini-lab on this web site. Click here to retrieve it. You will be responsible for understanding and completing it according to the directions given.

3/1/03

There is a possible bug in the Insertion Sort Code that you have obtained from Drexel's web site! As a result, your sort functions will not work. Many thanks to Shahab for finding this problem and producing a fix.

The following sort function will correctly sort an array of integers. Please modify it for use in your db class.

void insertionSort(int numbers[], int array_size)
{
     int i, j, index;

     for (i=1; i < array_size; i++)
     {
          index = numbers[i];
          j = i;
          while ((j > 0) && (numbers[j-1] > index))
          {
               numbers[j] = numbers[j-1];
               j = j - 1;
          }
          numbers[j] = index;
     }
}

2/26/03

Today I gave a demonstration of separating object oriented programs into their component files (.h, .cpp, and a driver file). Keep in mind that you may write many classes for your program (think about how you write dbclass and use apstring in addition to your driver file). So write your driver file last after you've carefully considered the design of your classes. It will save you time in the long run!

Remember that separating these files is very easy to do and simply requires some copy and paste. Don't forget to include the right header files in your program, and include the corresponding cpp files in your header (Turbo C++ annoyance!).

Later on we'll review Templates and Big O. Feel free to email me with any questions or issues!

2/12/03

Today we went over driver files and constructors by looking at the apstring class. You will apply the ideas that you've discussed to finish the qclass program. Those experiencing difficulty with the qclass should ask Mr. E., or a colleague, or of course you may e-mail me as well.

Please complete the sample multiple choice questions that you received today. I'd like to pick them up on Friday and look over them during the weekend so I can get you back a quick response regarding answers and explanations. If you don't have a copy of these questions please e-mail me and I'll send you one.

For more information on class design and constructors, please see one of these webpages from the CS 172 teachers at Drexel: [first lecture | second lecture]. They really do a fine job. He defines a class on English Lengths (and I also believe on Rational Numbers) that explains how constructors are created, etc.

As a good mental exercise, think about what kinds of constructors you might define for a "Fraction" class. Of course you must have a copy constructor and a default constructor (what would these look like?), but what other constructors might you define? In other words, what kinds of things might a user give to you to make into a fraction? Here's one for a clue: Fraction(double value); See if you can come up with the correct syntax for one default constructor, one copy constructor and 3 other constructors (including the one I just gave you). If you can do this, you're in pretty good shape at this point.

As a further summary, we decided that there are 3 kinds of constructors: a default constructor, a copy constructor, and other constructors. They all look the same, but the types of arguments that they take distinguish them from one another. For example, qclass() was our default constructor, and qclass(qclass value) would be our copy constructor. Other constructors, such as qclass(int pages, char data) or qclass(char data) are also legal and very helpful. The more constructors you make, the more ways you can create a variable (instance) of your class in main().

We will go over how to assign pointers later on, particularly how it relates to assigning data within an apstring.

Also, today we discussed the apstring for a short time and how it is used. Apstring is a class just like qclass or any other class; it was writtin in the same way and it will be used in the same way that you can use apstring in your programs. That's the beauty of making classes - you don't need to know how apstring looks on the inside, all you have to do is type apstring myString; in main() and you suddenly have a string. Apvectors and apqueues work in the same way, except that they had that extra <> on the line - you'll be going over this with Mr. E.

Finally a question was raised about the driver.cpp file. Driver.cpp is just a place to put your main() method. You would write it just like any other cpp file that you have before, except that you would put #include "qclass.h" at the top and you can create variables of qclass in your program. It is just as legal to put this code inside your qclass.cpp file. It's just a matter of cut and paste. It is, however, far more accepted to separate these files. If you look at the CS 172 links above, you will see that the examples consist of 3 files - a header file, an "implementation" cpp file, and another cpp file. This is the same as our "driver" file.

Wow, so how's that for a summary?

2/5/03

Today we solved the problem of the driver.cpp file. Add the line #include "qclass.cpp" at the end of you hearder file (but before the #endif), and it should work fine.

We also went over a free-response question from the AP exam regarding how to find modes. In doing this, we took a birds-eye look at the ap classes apstring and apvector. For now, the apvector can be treated as an array; we will discuss it later. The apstring, on the other hand, we will go into some detail about now.

2/3/03

The class made progress on its qclass development today. Here are a few notes:

First, remember to enclose your header file in a
#ifndef CLASS_H
#define CLASS_H
...
#endif

Second, remember that to return a qclass* (as with getFptr), your function should look like:
qclass* getFptr() { return fptr; }
Be careful not to add any extra "stars."

Finally, we were having trouble compiling our qclass.cpp, qclass.h and driver.cpp files on Turbo C. Well, I am having the same troubles getting similar class to compile on Turbo C on my PC, so we're either going to need to change compilers or write our main() function directly in qclass.cpp (you can just delete driver.cpp as we won't need it anymore).

Later this week we'll merge our code from the print queue into the qclass structure. Then we'll talk about some interesting features of classes, such as const parameters, operator overloading, etc., and we'll introduce strings into our project.

1/29/03

We talked about Stacks vs. Queue's today. Remember that stacks fill up like a stack of papers - you put one page on top of the other, but then you take one off the top when needed. So if you push A, B, and C to a stack, you would get back C, B, and A when you pop them. Queue's are the opposite. Think of a traffic queue or a line at the grocery store, the first one in line should be the first one served. The first car to pull up to the red light has been there the longest, and is the first to drive through when the light turns green.

After that, we worked on creating a skeleton class to hold your QNode program. When we are done with this we will change the char value in the class to a string. When designing classes, it is often easy to make a syntax error. From my experience, a good word of advice would be to create the class in small steps - perhaps with only one variable/getter/setter at a time, until it compiles. Then try to write a main() function in another file that creates your class and does something with it. See the point class below, perhaps try to replicate it on Turbo C++ and make it work. You'll have a much better understanding of classes if you do, and you'll have a good template to use in the future.

1/27/03

Just scratched the surface of Pass By Reference. Due to an error, I thought that the class had already covered Pass By Reference and that I was providing merely a review. A good overview can be found here. (Materials designed by Paul Zoski, Drexel University). Also reviewed a few sample problems on function analysis just to get a feel for what AP exam questions are like.

More importantly, the class has begun working with classes. Programming with classes is a fundamental component of a style of programming known as Object Oriented Programming. Rather than design classes right from the start, it might be helpful to look at how classes are used. For details, see the String class here. Actual design information can be found here. Finally, constructor information can be found here. (Materials designed by Paul Zoski, Drexel University)

I have written a sample class called "point" that shows how a typical if simple class might be written. A real program should be well documented and should follow other "good-coding conventions," but I have forgone such standards in favor of clarity here. The files are below:

    • point.cpp and point.h (which includes the class definition (dot h file) and implementation (dot cpp file))
    • driver.cpp (which includes the main function)
    • output.txt is what it looked like when I compiled it and ran it.

 

line

Copyright (c) 2005 William M. Mongan