Introduction |
Part A of this programming assignment is designed to ensure that you know how
to use linear linked lists (as opposed to arrays and hash tables)
to implement simplified versions of most of the collection classes that we
have seen (all but List): Stack, Queue,
PriorityQueue, Set, and Map; in the process, you'll
understand these collecton classes a bit better, when implemented from the
inside.
Part B is designed to ensure you know how to write simple recursive methods
that operate on simple recursive data structures: linear linked lists and
trees.
All these tasks will be described in greater detail below. Instead of starting with empty project folders, download and unzip the Start A Project Folders and Start B Project Folders which contains appropriately named folders. Write your code in these project folders, and when you are finished, zip each and submit it via Checkmate to the appropriate Part (A or B). There are no executables with this assignment. For the the collection classes, you can use my testing code to test your classes (you should understand the correct behavior). For the recursive methods, I have supplied tests (via JUnit) that your methods should pass. |
General Information | The second in-class programming exam will be taken directly from this assignment. You will be asked to implement one of the collection classes specified in Part A, and/or (I haven't quite made up my mind) one or two list and tree methods specified in Part B. I will make up my mind on the exact form of the exam by Monday, November 26. A practice exam (following this form) will be given on Monday, December 3, in lab. |
Part A Implementing Simplified Collection Classes With Linked Lists |
In Part A you need to implement the following collection classes with the
following kinds of linked lists.
Test your code to ensure the right exceptions are thrown too: my driver with catch the exception, print it, and keep testing your code. Here are the details.
|
Part B Simple List/Tree Algorithsm Written Iteratively (and/or Recursively) |
In Part B, you will have to implement various static methods that
operate on standard linear linked lists and binary search trees.
The start folder for this part is an Ecliplse project with four classes First, the LN and TN (list node and tree node) classes contain the instance variables and a few utility methods (mostly called in the JUnit testing code) for representing lists and trees. The Solution class is where students write their solutions to all the required static methods; it contains comments about and headers for each of the methods that you must write. Finally, the TestSolution class is a JUnit testing class for all the methods that you must write in Solution. Part of this assignment will allow you to become more familiar with JUnit test, and learn how to use and debug with JUnit tests. Note, that in TestSolution, each test method (e.g., testInsertAtRear, testInsertInOrder, etc.) will be called regardless of whether any other tests fail; to JUnit will test every method. Once in such a test method, its tests will either run to completion, with the method passing all its tests, or some test fail an "assertion": execution of the method stops after failing the first assertion, and leaves a record of the failure (by clicking you can find the nature of the failure, and on which line the assertion failed. The one exception to this rule is that if any method has infinite looping or recursion, no subsequent tests are done (and you can see the offending code as the last one tested -with the test not complete). Note that you can put System.out.println debugging statements in your code; its information will be printed on the console. I will state here unequivocally that the best way to debug your code is to do hand-simulations; the best thing you can do during this assignment is become proficient at hand simulating linked list code. Here are the general instructions for this part (in the Solution class). List Problems: In these problems you must return a list specified by the semantics of the method. You can mutate a parameter list, or construct a completely new list -whichever is simpler. You can write these methods iteratively or recursively, whichever is simpler. You may write helper methods, when appropriate. Tree Problems: In these problems you must return an int, String, or tree list specified by the semantics of the method. You must not change the parameter tree You must write these methods recursively. You may write helper methods, when appropriate. Here is a list of the methods with some hints about solutions. Generally, if there is a recursive solution, it is simpler than the iterative one.
|
Extra Credit | None for this assignment, beyond submitting early. |