What's New in CS367?


April 30
There will be no lecture on Monday, May 3. Also, Prof. Fischer's office hours on Tuesday, May 4 are cancelled. The lecture on Wednesday, May 5 will be held.

April 20
The final exam will be held on Wednesday, May 12, 10:05am - 12:05pm, in 132 Noland. The final exam will cover the entire semester.

March 18
A help page for assignment #4 is available.

March 18
Practice Problems for Midterm Exam are available.

March 16
The midterm will be held on Tuesday, March 23, 7:15-9:15pm in 5208 Social Science. Be sure to bring your Student ID card.

March 16
Assignment #4 (due on April 7 at midnight) is out.

February 22
A number of students have asked if it is ok to copy the linked list into an array, then use an array-based merge sort, and finally copy the array back into the linked list. First, this method requires an array to copy the linked list into. You also need a temporary array for doing the array-based merge sort. This method is wasteful from a memory usage standpoint. Second, a goal of this assignment is for you to learn about using and manipulating linked lists. As a result, you are not allowed to use this solution. In fact, you are not allowed to use an array for temporary space anywhere during the mergeSort solution.

February 11
Several students have been confused about how to test for whether an Object is in the list in Part 3 of Using the List Class (3.). The Note suggests you look at the equals method. He is a brief discussion of the alternatives:

If you do the following:

public class foo {
    public static void main(String [] args) {
        Integer i1 = new Integer(11);
        Integer i2 = new Integer(11);
        boolean t1 = (i1 == i2);
        boolean t2 = i1.equals(i2);
        System.out.println("t1 = " + t1 + " and t2 = " + t2);
    }
}

You get:
t1 = false and t2 = true

What is going on here?
== of two objects tests if they refer to exactly the same object. You could get this to happen by doing: i2 = i1; It does not test if what the object represents is the same. Here i1 and i2 are both Integers storing the integer value, 11. If you want to compare values you use the equals method. This is why t1 is false and t2 is true.

When you create a class, you inherit an equals method. If no subclass changes the meaning from the Object class (from which all classes are derived) then it compares the reference just like ==. However, it is good practice to provide your own equals method for a class if you can compare two instances of a class. The Integer class does this so equals compares the ints the object refers to. This is what people expect from the equals method.

What does this mean for the assignment?

When you look for items on a list, you usually prefer to see if what the object represents (not the reference) is the same. Thus, it is usually preferable to use the equals method. If you haven't done this yet then use this way. However, a number of people were confused about what to do and used ==. If you already did this then it is ok for this assignment. You will get credit either way as long as it works correctly for what you did.

February 9
If you've already implemented the PiEstimator class, you will have noticed that ComputePi takes quite some time to execute as n increases. Why? Here is an explanation (it's a matter of algorithmic complexity!).

February 9
To better understand the concept of algorithm complexity you should try some of the exercises at the end of Chapter 5 (particularly questions 6, 10 and 14). Here are our answers in case you want to check your solutions.

February 4
In part 2 of assignment 2 (on page 2), the file you should hand in is SortVector.java (not SelectionSort.java). The error has been corrected on the assignment's Web page.

January 28
Assignment #2 (due on 2/12 at midnight) is out.

January 27
Instructions on how to handin Assignment #1 electronically are now available.

January 19
Assignment #1 (due on 1/29 at midnight) is out.

January 19
Java help sessions are planned.