Question: 9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a lot of methods from SLList because the CircularQueue

9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. Youwill be deleting a lot of methods from SLList because the CircularQueue

9.2 Rewrite the SLList implementation and call the new implementation CircularQueue. You will be deleting a lot of methods from SLList because the CircularQueue API is much smaller in comparison: the entire CircularQueue API has four methods described in Table 9.3. Your CircularQueue implementation must meet the following specifications: 1 2 3 4 5 6 7 8 9 Your CircularQueue implementation will use a circular linked list, which is the same as a linked list except that no links are null (that is, no node's next field is ever null) and the value of last.next is first whenever the list is not empty. CircularQueue keeps only one Node instance variable last. > CircularQueue has a private inner class called Node, just like SLList, except that CircularQueue's Node is simpler and is exactly the same as what's shown on lines 5 - 8 below: public class CircularQueue { private Node last; // references the most recently added Node private int n; // number of Nodes in this CircularQueue private class Node { E data; Node next; } 10 11 | // Other methods follow (With this Node class, your addLast and removeFirst methods will have to do the work that was previously done by the Node constructor in SLList. Also note that you will be renaming addLast to enqueue and removeFirst to dequeue.) > All of CircularQueue's public methods are shown in Table 9.3. void E } Table 9.3 CircularQueue API int Method enqueue (E element) dequeue () boolean isEmpty() size() What it does Inserts element as the last element of the Queue Removes and returns the first element of the Queue (the element that has been in the Queue the longest) Returns true if the Queue is empty and false if it isn't Returns the number of items in the list

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 Programming Questions!