|
Assignment 7The Assignmenthttp://learnu.ics.hawaii.edu/~nickles/211_Spring_2005/labs/ priority_queue/PriorityQueue.htmlSubmission
RecommendationsMost of the code for the Heap is in your book. Read pages 519 through 532 to learn more about heaps and priority queues. There will likely be some differences--the book uses KeyedItems, where you will use Comparables. There may be other small differences. But the general algorithms for adding to and deleting from a Heap are there and should be a help. Remember, your heap should take Comparable objects; it shouldn't know anything about PrintJobs or other specific classes.
I recommend you write your heap as a separate class (Heap.java) and then use it in your PriorityQueue. (You may combine the two if you wish.) You must use a static data structure and the "(index * 2) + 1" formula. You may use an array, though I would recommend using a Vector. A Vector will grow as needed so you don't have to worry about the heap ever being full; and it has a Remember that the examples in the book assume that the object with the highest value key has the highest priority. Your heap should assume that the lowest value has the highest priority. The two given queue exceptions do not compile under Java 1.3. Just comment out the two constructors that take Throwable objects. Also, you may comment out the package statement at the top of PriorityQueue if you are having trouble compiling. Here is a short grader to check your PriorityQueue. You may have to run your own tests and do some debugging before you can pass this grader correctly. And remember this grader does not test exhaustively. When you are done, try compiling and running Simulation with your PriorityQueue. It should throw no exceptions and print jobs in the correct order of fewest pages first. Grading:Out of 10 points:
SolutionZach's Solution (zip file). |
~ztomasze Index :
TA Details: ICS211:
Assignment 7 http://www2.hawaii.edu/~ztomasze |
Last Edited: 25 Apr 2005 ©2004 by Z. Tomaszewski. |