Question: Objective: The goal of this assignment is to practice Queue operations Assignment: Consider the following array-based Queue class public class Queue ( private int QUEUE


Objective: The goal of this assignment is to practice Queue operations Assignment: Consider the following array-based Queue class public class Queue ( private int QUEUE SIZE-5; private Object] items private int front, back, count; public Queue ) items = new Object(QUEUE SIZE]; front = 0; back - QUEUE SIZE -1; count =0; public boolean isEmptyO return count-=0; public boolean isFul1 return count -- QUEUE SIZE; public void enqueue (Object newItem) if (isFull) back = (back+1) % QUEUE SIZE; items [back] = newItem ; count+t; return; else System.out.println ("Trying to enqueue into full queue") public Object dequeue ) if (isEmpty )) Object queueFront - items [front]; front = (front+1) % QUEUE. SIZE; count--; return queueFront else System.out.println ("Trying to dequeue from empty queue return null; public void dequeueAll items -new Object [QUEUE SIZE] front 0; back - QUEUE_SIZE -1; count =0; public Object peek ) if (isEmpty )) return items[front]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
