The queue is another special linear data structure that follows the First-In, First-Out (FIFO) principle. There are two ends for the operation: one to append to the queue and one to remove from the queue. This is different from a stack, where we used one end for both the add and remove operations. The insertion will always be at the back or rear section. The removal of an element will take place from the frontend. The process of adding a new element to the queue is known as enqueue and the process of removing an element is known as dequeue. The process of looking at the front element of the queue without removing the element is known as a peek, similar to the top operation of a stack. The following figure depicts a representation of a queue:
Now, if we define an interface for a queue, it will look like this:
interface Queue {
public function enqueue(string...