Question
Need help completing the starter code for the Queue class. The starter code is below package queue; /** * A circular singly-linked queue ADT implementation
Need help completing the starter code for the Queue class. The starter code is below
package queue; /** * A circular singly-linked queue ADT implementation */
public class Queue
/** * the number of nodes in this queue */ long length;
/** * this inner class is used to create nodes of the queue */ private class Node { public E data; public Node next; }
/** * Creates an empty queue */ public Queue() { //Implement this method. }
/** * Determines whether the queue is empty. * @return true if the queue is empty; * otherwise, false */ public boolean isEmpty() { //Implement this method. }
/** * Inserts an item at the back of the queue. * @param data the value to be inserted. */ public void enqueue(E data) { //Implement this method. }
/** * Accesses the item at the front of a non-empty queue * @return item at the front of the queue. * @throws Exception when this queue is empty */ public E front() throws QueueException { //Implement this method. }
/** * Deletes an item from the front of the queue. * @return item at the front of the queue. * @throws Exception when this queue is empty */ public E dequeue() throws QueueException { //Implement this method. }
/** * Gives the size of the queue. * @return the size of the queue */ public long size() { //Implement this method. } /** * Moves the element at the front of the queue to the back. */ public void rightRotate() { //Implement this method. }
/** * Moves the element at the back of the queue to the front. */ public void leftRotate() { //Implement this method. } /** * Gives a string representation of the elements of this queue * in the format [en-1, en-2, ...e3, ,e1, e0], where each ei is an * element of this queue and e0 is the element in the head node and en-1 * is the element in the rear node. It returns [] if this queue is empty. * @return a string representation of the queue in the format * [en-1, en-2, ...e3, ,e1, e0] */ public String toString() { //Implement this method. }
Cs li 1351-03.05, pring 2017. Lab 9: Project Queue S a Project impl ar named Queue that illustrate data tYPe the implementation of menting a Linear Abstract Data Type In le cture class that presented a generic consists data field and one Queue abstract data type (ADT with an inner Node that implementation. the head and 1 A some method queue is external reference. The Queue E class had two rear no operations threw a user-defined exception add the element that append an element to its rear and remove (dequeue) the re- DEFINITION at its head objects. 2. An abstract data type (ADT) an object whose instances are a collection ot other o An ADT objects and allows access via specific rules. An ADT is also referred as a container. Its size depends on the number of objects (elements) it contains. In this lab, you will complete the implementation of a variant the Queue E> ADT that consists of circular singly linked o queue has three basic methods allocated nodes with the rear pointing to the head dequeue and front used to add, remove and access elements: enqueue the front of the are used to add an to back the an element from respectively. queue, and access the element at the the e removing it The Java front of queue without standard library Exception is thrown whenever an exception occurs The Generic QueueAPI
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