Queue is a linear data structure consisting of a collection of elements in FIFO (First In First Out) order

Basic operations

  • Insert aka Enqueue, adds an item onto the end of the queue
  • Remove aka Dequeue, retrieves and removes the head of the queue
  • Examine, retrieves, but does not remove, the head of the queue

Other operations

  • isEmpty returns true if no more items can be dequeued
  • isFull returns true if no more items can be enqueued
  • size returns the number of items on the queue

Implementation

You can implement a queue with either a Linked List, a Static Array (capacity restricted) or a Dynamic Array

Queue implementation example with Static Array


Applications

  • Breath First Search uses a queue to track which elements to visit next