# Queue **An abstract data type that organises a collection of elements in first-in first-out order.** ![[Queue.svg|500]] *A queue, with an element being enqueued and dequeued* A *queue* organises a collection of elements such that the order in which they are added to and removed from the queue is *first-in first-out*, often shortened to *FIFO*. That is, the earliest element added to the queue will be the first to be removed. It thus differs from a [[stack]] which operates in LIFO order. The end to which the elements are added to is known as the *back* of the queue and the end from which elements are removed is known as the *front* of the queue. A queue is so called as to serve as an analogy to a queue of people waiting to be served. The person that arrived the earliest should be served first. ## Operations ### Essential operations - `Enqueue` - adding an element to the collection - `Dequeue` - removing the earliest added element from the collection ### Non-essential operations - `Peek` - observing the element at the front of the queue ## Applications - [[Breadth-first search]]