What is a Queue? FIFO

A Queue is a data structure with two key functions enqueue and dequeue. The enqueue function will insert an item into the front of the queue and the dequeue function will remove the item at the end of the Queue.

Queues operate on a First in First Out basis meaning the item which has been in the Queue the longest will be the next one to be removed.

Operation Queue State - Front of the Queue is to the left
Initialize Empty Queue []
queue.enqueue(1) [1]
queue.enqueue(2) [1,2]
queue.enqueue(3) [1,2,3]
queue.dequeue() [2,3] : returns 1
queue.dequeue() [3] : returns 2
queue.enqueue(4) [3,4]
queue.enqueue(5) [3,4,5]
queue.dequeue() [4,5] : returns 3