Priority queue

In computer science, a priority queue is an abstract data type similar to a regular queue or stack abstract data type.

In a priority queue, each element has an associated priority, which determines its order of service.[1] The order of service is largely based on implementation. Traditionally, scholars describe priority queue as serving highest priority first.[1] However, in modern software it is merely an implementation detail. For example, in Java standard library, PriorityQueue serves lowest priority first by default.[2]

While priority queues are often implemented using heaps, they are conceptually distinct. A priority queue can be implemented with a heap or with other methods; just as a list can be implemented with a linked list or with an array.

  1. ^ a b Miller Jr., Robert G. (1960). "Priority queues" (PDF). The Annals of Mathematical Statistics. Stanford University.
  2. ^ "PriorityQueue (Java SE 9 & JDK 9 )". docs.oracle.com. Retrieved 2025-03-13.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search