CSCI 221
Assigned Date: Wednesday, November 17, 2004
Unit Tests and Javadoc Due: Monday, November 22, 2004
Email to announce teams: Thursday, November 18, 2004, 5 PM
Complete Project Due: Wednesday, December 1, 2004
Due Time: Noon

Updated:   Tuesday, November 18, 2004, 18:15 PM
Friday, November 19, 2004, 10:00 PM



This assignment focuses on sorting, queues, linked data structures and unit testing. 



See previous assignment.



Develop a queue ADT, called RPQueue. 

This ADT should implement Dale’s PriQueueInterface, (see p. 613 of textbook).  Additionally, it should implement method Reverse(), which sorts the queue in reverse order every time called. 

Initially, the queue should be ordered in increasing order from the rear to the front.  In other words, Dequeue() should return the front item which, initially, should be the item with the highest value.  After Reverse() is called once, Dequeue() should still return the front item which, now, should be the item with the lowest value.

There should be two RPQueue constructors: the default, which creates a queue with capacity of 100 elements; and one that expects capacity (and int) as its only argument.

The ADT should be robust (not “by contract”).  Use Java’s assert to test the preconditions of each method.



  1. Implement an inner class, called Memory, which encapsulates the array data structure (see p. 427).  This class should provide two constructors similar to RPQueue, and two public methods:
  2. Beware of memory leaks -- when dequeuing items, return their memory to the free list.
  3. Use an instance variable order, which takes values INCREASING and DECREASING (defined as final bytes). 
  4. Be elegant in your design.  For example, there is a simple way to effect reversible sorting, given the order variable. 



You should submit your source(s) on a floppy disk, as per syllabus instructions. 

Source filenames to be submitted: 

A zip archive named <firstName_lastName_fourLastDigitsOfSSN> (for example,  This archive should contain the following files:

·        RPQueue (the BlueJ project directory).  Within RPQueue there should be the following files:

o       Readme.txt (see Widget for a sample)

o       Any files generated automatically by BlueJ (e.g., bluej.pkg, bluej.pkh, etc.)


o       A doc subdirectory with the Javadoc API documentation generated by BlueJ, for RPQueueInterface and RPQueueTest.

Note: If you are working with a partner, the name of the zip archive should contain the names of both partners as follows: <firstName_lastName_fourLastDigitsOfSSN_AND_ firstName_lastName_fourLastDigitsOfSSN>  Ensure that the documentation is updated appropriately, including the Certificate of Authenticity.