Implement three priority queues according to the PriorityQueue interface
provided. You should provide the
following implementations:
Each heap implementation should be in its own file (BinaryHeap.java, ThreeHeap.java, MyHeap.java). Implement the BinaryHeap
(a binary min heap) as discussed in lecture.
For the ThreeHeap we suggest starting with a
copy of your BinaryHeap code and making changes as
necessary. Your ThreeHeap
should still follow the contiguous structure (complete tree) form of the binary
min heap discussed in class. For your third heap
implementation, feel free to get creative.
The simplest possible implementation might just use an array (sorted or
unsorted), a linked list (sorted or unsorted) or a tree. Whatever you do, be sure it implements the PriorityQueue interface
provided, and does not use parts of the Java collections framework. Your priority queues only need to work with
doubles.
Your implementations should automatically grow (if
interested you may also make them shrink - this is optional) as necessary. Note: Growing an array implementation one
element at a time is not likely to be the most time efficient solution, and you
should NOT use Java class libraries (no import statements).
Provided code:
We will be testing the code that you submit -
so we will expect that you have done the same!
(We will
also be asking you to turn in your testing code.)
Grading: each data structure is worth 11 points, which is 33 points total. Insert(): 4 points, DeleteMin(): 4 points, and isEmpty + makeEmpty(): 3 points. Any mistakes elsewhere like in the constructor() could lead to a points reduction too if it makes these functions not work well. There are another 8 points for style such as poor comments, inefficient design, didn't follow directions (including all code) etc. For this assignment we will be grading more strictly for things like style and efficiency than we did on HW #1.
This week your write-up involves a comparison of your three
heap implementations. I would expect
these reports to be a couple of pages long, potentially longer if you include
many graphs or tables. Exceptional
reports may be awarded a small amount of extra credit, so have fun with this! Please prepare a report that addresses the
following:
Electronic Turn-in should include the following files:
Above and Beyond:
There are no explicit above and
beyond options for this assignment, but exceptional reports may receive small
amounts of extra credit. You might also
consider implementing several different heaps from very simple to very complex
(the book discusses Leftist, Skew, Binomial Queues, and Fibonacci). If you implement other heaps and discuss them
in your report, please include the Java code for those heaps as well. The file named MyHeap.java
is the one that will be graded as part of the original assignment.