Question: In a new file, type in the code for the generic queue interface. public interface Queue { public boolean isEmpty(); public void enqueue (Any Type

 In a new file, type in the code for the generic

In a new file, type in the code for the generic queue interface. public interface Queue { public boolean isEmpty(); public void enqueue (Any Type x); public Any Type dequeue(); public Any Type peek(); Create your own class that implements the Queue interface. Your queue should contain a reference to the doubly linked list you made in Lab 3. Modify your list as necessary to support constant time insertions and deletions from both the front and end of the list. Implement the enqueue () method which inserts an item into the end of your queue. Implement the dequeue() method which removes and returns the item at the front of the list. If the list is empty, the dequeue method should return null. Implement the isEmpty() method to determine if the queue is empty and use it in the dequeue() method. Implement the peek () method that returns, but does not delete, the first item in the queue. Duplicate the same tests you did for your stack with the queue (i.e.insert the same items, check if the list is empty, peek, and remove the items in the same order). Note the how both data structures store the same data but in different orderings. In a new file, type in the code for the generic queue interface. public interface Queue { public boolean isEmpty(); public void enqueue (Any Type x); public Any Type dequeue(); public Any Type peek(); Create your own class that implements the Queue interface. Your queue should contain a reference to the doubly linked list you made in Lab 3. Modify your list as necessary to support constant time insertions and deletions from both the front and end of the list. Implement the enqueue () method which inserts an item into the end of your queue. Implement the dequeue() method which removes and returns the item at the front of the list. If the list is empty, the dequeue method should return null. Implement the isEmpty() method to determine if the queue is empty and use it in the dequeue() method. Implement the peek () method that returns, but does not delete, the first item in the queue. Duplicate the same tests you did for your stack with the queue (i.e.insert the same items, check if the list is empty, peek, and remove the items in the same order). Note the how both data structures store the same data but in different orderings

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!