Question: Write a program that implements an Array-based Queue . You should implement the following methods : {enqueue, dequeue, front, size, isEmpty, isFull, display and search.
Write a program that implements an Array-based Queue. You should implement the following methods : {enqueue, dequeue, front, size, isEmpty, isFull, display and search.
• search() which searches the queue for an element, and return this element if it found it. Otherwise, it displays a messages indicates that the element is not found.}
Test the queue by building the following example:
enqueue(Sara), enqueue(Hdeel), enqueue(Khlood), display(), dequeue(), dequeue(), display(), enqueue(Rneem), isEmpty(), front(), display(), dequeue(), size(), dequeue(), front(), enqueue(Eman), enqueue(Ahlam), enqueue(Huda), dequeue(), search (Ahlam)
Finally, whenever the method has a returning value, you should display this returned value (you can just use print or display for that).

// Java program to implement a queue using an array class Queue { private static int front, rear, capacity; private static int queue []; Queue (int c) { } front = rear = 0; capacity = c; queue = new int [capacity];
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
Answer class ArrayQueue def initself capacity selfcapacity capacity selfqueue None capacity selffron... View full answer
Get step-by-step solutions from verified subject matter experts
