Lab 3 - How Fast is Java?
Due: Monday, October 4, 2004 at 9:00 AM

Short Answers

Complete the following problems from the book and turn them in as a text file lab3.txt at the start of lab.



Part of your lab writeup will involve making graphs of timings you gather. You may use any software you like. One option available on our computers is gnuplot. Try out some of the examples from the gnuplot tutorial.

The file

in the Mac lab or
on FreeBSD contains a script for gnuplot to get you started. Once you generate a postscipt file, use the command open on the Macs or gv on the FreeBSD systems to open it in a viewer. You can print it to the printer using the lpr command.

To practice, plot functions that are O(1), O(n), O(n2). In addition, copy the file unknown.dat from the same directory as the starter script. Plot the data in that file. (What do you think it represents?) You do not need to hand in any of the plots from this section.


Do the laboratory at the end of Chapter 4. You should read and think about the lab before Wednesday. Since you will write only a few small programs, you do not need to bring a design.

Programming Hint: When you run your programs, use java -Xint. The -Xint flag will turn off dynamic optimizations. This will give you more accurate results.

Turn in a writeup of the results of your experiments as a postscript or PDF file called or lab3.pdf. This formal lab writeup should include:

Good technical writing style is expected. State any assumptions clearly and justify your conclusions. You should plan to spend more time gathering and analyzing data and writing your report than on the programming.

If you want to practice being a real computer scientist, you can do your writeup in the typesetting language LaTeX, which is used to generate all handouts for this course, was used to write our textbook, and is the most widely-used system for generating technical research papers. An example LaTeXdocument can be found on the FreeBSD systems at


This is not required, however, and you are free to use the document preparation tool of your choice, so long as it can include the necessary graphical objects for the writeup of step 7 of the lab procedure, and can produce a postscript or PDF file that you can submit.