Queues in a nutshell
A queue is a linear data structure that uses the First-In-First-Out (FIFO) principle. Think of people standing in a queue to buy stuff. You can also imagine ants that are walking in a queue formation.
So, technically speaking, the elements are removed from the queue in the same order that they are added. In a queue, the elements added at one end referred to as the rear (this operation is known as the enqueue operation) and removed from the other end referred to as the front (this operation is known as the dequeue or poll operation).
The common operations in a queue are as follows:
enqueue(E e)
: Adds an element to the rear of the queueE dequeue()
: Removes and returns the element from the front of the queueE peek()
: Returns (but doesn't remove) the element from the front of the queueboolean isEmpty()
: Returnstrue
if the queue is emptyint size()
: Returns the size of the queueboolean isFull()
: Returnstrue
if the queue...