Queue
A Queue is a special kind of list that is designed specifically for
elements to be added to the end of the list and removed from the
beginning of the list.
Implement the Queue class. You may only
use Stack(s) as the underlying structure for storing data. The Stack is
assumed to be a generic class and has the 5 methods below. This is the Stack ADT we discussed and started together in class or the first problem in this set.
Be sure to write unit tests and be able to show them when asking for help. Look at this example unit test writing if needed.
Here is a video explanation of how to implement a Queue using Stacks. Be sure to watch this and be able to discuss it when asking for help!
void enqueue(T el): add element el to the queue. T dequeue(): remove the first element in the queue
int size(): return # of elements in the queue
T peek(): return the first element in the queue without removing, null if empty.
boolean empty(): return true if the queue is empty, false otherwise String toString(): return a String representation of the queue in the format [el1, el2, ..., elN]
Type your solution
Skills Practiced:
3.A
3.C
4.A
4.B
Saved
Saved