Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started