Question
THIS IS IN JAVA Implement a generic array based on FIFO Queue that contains the following attributes and operations: -size: # of elements in this
THIS IS IN JAVA
Implement a generic array based on FIFO Queue that contains the following attributes and operations:
-size: # of elements in this queue, 0 when queue is empty
-front: index of the front element
-back: index of the back element
-CAPACITY= 10: initial length of the container
-container: generic array, initially at given capacity
OPERATION:
-enqueue: insert a new element at the back of this queue. if array container is full, the container should be expanded by creating a new larger container, and preserving all the elements of the queue in FIFO
-dequeue: remove the element at the front of this queue, return null if queue is empty. All remaining elements of the container should be shifted one postion towards the front during dequeu.
-isEmpty: return true if this queue has no elements, otherwise return false
-peek: return the front element of this queue, return null if this queue is empty
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