Question: import java.util.NoSuchElementException; import java.util.Date; //for testing //priority queue where the minimum item has the highest priority class PriorityQueue extends SimpleQueue { //updates an item that's
import java.util.NoSuchElementException; import java.util.Date; //for testing
//priority queue where the minimum item has the highest priority class PriorityQueue
//You may need to override some other methods from SimpleQueue! //Restriction 1: all methods from SimpleQueue should still work //(as in, if you add(), the value should be added, if you call //size() it should return the correct value, etc.). However, //remove/poll will remove the _minimum_ value from the queue; //element/peek will return the _minimum_ value from the queue.
//Restriction 2: element() and peek() must still both be O(1) //------------------------------------------------------------- // Main Method For Your Testing -- Edit all you want //------------------------------------------------------------- public static void main(String[] args){ PriorityQueue
dates[3].setTime(0); values.update(dates[3]); System.out.println(); for(Date d : values) { System.out.println(d); } if(values.peek().equals(dates[3])) { System.out.println(" Yay 1"); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
