In computer science, a priority queue is an abstract data-type similar to a regular queue [Queue] or stack data structure in which each element additionally has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority.


To improve performance, priority queues are typically based on a heap [Heap], giving O(log n) performance for inserts and removals, and O(n) to build the heap initially from a set of n elements.

(“Priority Queue” 2022)