Queue

Queue is a linear data structure for storing and retrieving data. A queue provides special methods to insert (push), remove (pop), or inspect (peek) elements in certain orders.

FIFO queue


A FIFO queue, or first-in-first-out queue, is a basic type of queue with addition operations at the end and removal operations at the front.


 * Push: To add an element at the end of the queue.
 * Pop: To remove an element from the start of the queue, i.e. the least recently added element.

Deque
A deque (pronounced deck), or double-ended queue, is a special type of queue that allows insertion / deletion / inspection of elements at both ends.

Circular queue
A circular queue is a queue whose tail is connected to its head. It is also called a "ring buffer". It is often used for optimizing space use when the space size is fixed.

Some applications include:
 * Memory management
 * Traffic system
 * CPU Scheduling

Sample problems

 * Tree printout by level
 * Sliding window problems

Association with stack

 * Implement stack using queues

C++

 * cplusplus.com: queue
 * cppreference.com: ,

Java

 * The  interface: Interface
 * The  interface: Interface
 * The  class: Class