Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 implements QueueAPI { /** * A reference to the back of the queue */ Node rear;

/** * 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. }

image text in transcribed

image text in transcribed

image text in transcribed

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 Interface The generic QueueAPI interface is available tor Moodle that con nload in the zip file on ains the starter code for this lab. lt defines a set of that the generic queue whose mplementation you will complete must have. he Generic Queue Class his is a generic queue implementation. An incomplete version of the code is the im in the starter code for this lab. Complete C of a generic Queue class that implements the QueueAPI intertace. The

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions