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: QueueAdd

Here’s an image depicting what removing an element from a queue looks like conceptually: QueueRemove

Advantages/Disadvantages of Queues:


  • fast access for adding/removing an element
  • essential for solving certain problems (ie. breadth first search)
  • can be implemented easily (similarly to a linked list)


  • limited use cases, not as generally useful as a list or array
  • unable to iterate through a queue

You may notice that the advantages/disadvantages to queues is awful similar to stacks!

Data Structures