MIDTERM 2
CS203, Spring 2006


Please upload your source code and other files using CSNS at the end of the exam. Note that file uploading will be disabled automatically after 3:30PM, so please turn in your work on time. Before turn in your programs, try to compile and run them and make sure they work correctly. If your program does not even compile, you receive an automatic 50% credit deduction for that problem, no matter how "close" the program seems to be correct.

Consider an OrderedLinkedList class, which is similar to the DoubleLinkedList class we implemented in Homework 1, except that the nodes in the list are always sorted based on the value field in the ListNode class. Note that there is a class variable order in the OrderedLinkedList class, which indicates whether the nodes are sorted in ascending order or descending order. For this problem, you must complete the OrderedLinkedList class by implementing the following two methods:

The worst-case complexity of all the methods above must be linear or better; otherwise you will not receive any credit. You may add more methods to the OrderedLinkedList class if necessary, however, you may not add or remove any class variables, and you may not change the ListNode class in any way.