Question: QUESTION: Add code to the Queue code posted to implement circular and priority queue. Add your comments based on the assumptions you have made. Submit

QUESTION:

Add code to the Queue code posted to implement circular and priority queue.

Add your comments based on the assumptions you have made.

Submit the code in word document.

public class Queue { int capacity;//amount of data int size;//size is current number of elements in queue int[] data; int front;//first element in queue in order and used only for delete int rear;// last index of array Queue(int max) { capacity=max; data=new int[max]; front=0; rear=-1;//rear=0; size=0; } //add, remove, read void addData(int val)//add data to queue is call enqueue { //always check if queue has space or not if(size0)//checking if queue is empty or not { size--; return data[front++]; } else { System.out.println("Queue is empty"); return -1;//queue can only hold positive values } } //read the data }

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