Priority queue

Also known as: PQ

A priority queue stores elements with keys and always supports “extract the best key” (min or max), plus insert. A binary heap is the usual implementation; Fibonacci heaps appear in theory for better amortized decrease-key.

Dijkstra, A*, event simulators, and Huffman coding are consumers. It is not a FIFO queue: order is by priority, not arrival.

Operations are typically $O(\log n)$ per insert/extract with a binary heap; peek is $O(1)$.

← Back to CS Glossary