Question: In data structures, a queue is a data structure that is first in, first out. It contains two methods: enqueue - adds an item to

In data structures, a queue is a data structure that is "first in, first out". It contains two methods: enqueue - adds an item to the queue dequeue - removes an item from the queue For this assignment you are going to implement a variation on this called a priority queue, where an integer corresponding to the priority is passed into the enqueue method upon invocation. As an example, we can have three successive calls to add items to the queue: q.enqueue("X", 10) q.enqueue("Y", 1) q.enqueue("Z", 3) Invoking dequeue on the object will then remove the item "X" from the queue, since it has the highest priority. A second invocation of the method returns "Z" while the third invocation returns "Y". Use an ArrayList as a representation of the queue. Include a main method which demonstrates successive adds and removals from your queue. Save your solution in a file named PriorityQueue.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
