Question: Build and use your own minimal queue class using an array of type String of fixed size to hold the queue. The array should have

Build and use your own minimal queue class using an array of type String of fixed size to hold the queue.

The array should have the default size of 5.

The array size should be setable via a constructor.

The following methods must be implemented:

enqueue inserts a value at the rear of the queue

dequeue returns the value at the front of the queue, removing the value from the queue

isEmpty returns true if the queue is empty, false otherwise

isFull - returns true if the queue is full, false otherwise

Tip: In a queue of 2 or more elements, the index of the rear is larger than the index of the front EXCEPT, the queue will need to wrap around the array. For example: If the array is 20 elements. the queue front is at index 15 and the queue rear is at index 19, the next enqueue will be at index 20, which doesn't exist. The index must wrap around the array, i. e. the next enqueue will be at index 0. The solution is to modulus by the array size whenever increasing an index, either rear of front. For example, to change the index of the rear to the next index,use the formula

rear = (rear + 1) % arraySize;

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!