Question: JAVA) Please solve this one. I need output too. And I need to create a class which returns the iterator. Thank you Priority Queue Implement

 JAVA) Please solve this one. I need output too. And I

JAVA) Please solve this one. I need output too.

And I need to create a class which returns the iterator.

Thank you

Priority Queue Implement a priority queue capable of holding objects an arbitrary generic type T, by defining a generic PriorityQueue class that implements the queue using an ArrayList. A priority queue is type of list where every item added has an associated priority and has the following methods: a.Add(T) - Adds a new Comparable item to the list. b. Remove() - Returns the item with the highest priority and removes it from the queue. If a user attempts to remove from an empty queue, return null. c. An getIterator that returns an iterator that implements the Iterator described below. interface MyIterator{ { boolean hasNext(); T next(); Tremove(); //Not common to implement these in iterators } Use the CompareTo method in the Comparable interface to compare the priority of object. You can implement the priority queue by performing a linear search through the ArrayList. If you are unsure of the generic types you can implement the same using a non-generic implementation. Just assume T as Object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!