Question: - Implement a queue using an array - Implement queue methods (enqueue/add, dequeue/remove, etc.) - Test the queue in a main() method Design a class
- Implement a queue using an array - Implement queue methods (enqueue/add, dequeue/remove, etc.) - Test the queue in a main() method Design a class named Queue for storing integers. (Do not use the inbuilt Queue class) The class contains: - An int] data field named elements that stores the int values in the queue. - A data field named size that stores the number of elements in the queue. - A constructor that creates a Queue object with default capacity 8. - The method enqueue(int v) that adds v into the queue. - The method dequeue() that removes and returns the element from the queue. - The method empty() that returns true if the queue is empty. - The method getSize() that returns the size of the queue. Implement the class with the initial array size set to 8 . The array size will be doubled once the number of the elements exceeds the size same as we did in the stack concept. After an element is removed from the beginning of the array, you need to shift all elements in the array one position to the left. Write a test program that adds 15 numbers from 1 to 15 into the queue then
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
