Author | Message |
---|---|
astrong2
Posts: 25
|
Posted 10:09 Mar 23, 2018 |
When I use the code from CSNS for the lab, it's telling me to delete the Override statements. Am I missing something or am I supposed to implement/extend something else? |
buensons
Posts: 5
|
Posted 10:29 Mar 23, 2018 |
You're supposed to create an interface very similar to PriorityQueue interface in net.datastructures package but instead of min and removeMin methods, create max and removeMax. Then implement this interface by creating abstract class the same as AbstractPriorityQueue class in net.datastructures package (just copy the code and name it MaxAbstractPriorityQueue or whatever. Oh and make sure it implements the interface tou created). After creating these 2 files, you can extend your MaxAbstractPriorityQueue or however you named it, with your MyMaxPriorityQueue class from csns. Professor said that this class will be almost the same as HeapPriorityQueue class, but just change upheap() and downheap() methods so they work for this maxPriorityQueue. Basically you have to change like 3 lines of code in that file. Hopefully I helped Last edited by buensons at
10:35 Mar 23, 2018.
|
jungsoolim
Posts: 38
|
Posted 10:35 Mar 23, 2018 |
Please look into the example of Min-Heap priority queue. 1) You will need to create an interface for Max-Heap similar to PriorityQueue, but it should have max() and removeMax() instead. 2) Then, you will created an abstract class similar to AbstractPriorityQueue by implementing the interface. 3) Finally, you will extend the abstract class to MyMaxPriorityQueue. In your MaxPriorityQueue, you will implement max() and removeMax(). In order to implement max() and removeMax(), you need upHeap(...), downHeap(...), and heapify(...). Please look into the example of min Heap in chapter 9 and see what you need to do to implement max heap. |