Conceptually a queue is similar to standing in a line. The people in the front of the line are served first. Newcomers start in the back of the line. They must wait for everyone in front of them in the line to be served. A queue works like a virtual version of a line. Elements are added to the back of a queue. Removing an item from a queue gets the first item that was added to the queue. A queue is often referred to as First In First Out (FIFO). This refers to the order in which elements are added and removed from a queue.
Here’s an image depicting what adding an element to a queue looks like conceptually:
Here’s an image depicting what removing an element from a queue looks like conceptually:
Advantages:
Disadvantages:
You may notice that the advantages/disadvantages to queues is awful similar to stacks!