Question: Implement a generic array based on FIFO Queue that contains the following attributes and operations: -size: # of elements in this queue, 0 when queue

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

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!