Priority Queue Data Structure is a regular Queue Data Structure with additional properties

  • Each element has a priority associated with it
  • An element with high priority is served before an element with low priority
  • If two elements have the same priority, they are served according to the order in which they are enqueue

Basic operations

  • enqueue(element), inserts an element into the queue with an associated priority
  • dequeue(), retrieves and removes the highest priority element
  • front() aka peek(), retrieves without removing the highest priority element


You can implement a priority queue with either an array, a linked list or a heap (although priority queues conceptually distinct from heaps)

Implementation example with a max heap

MaxHeapByArray is defined in Heap Data Structure