Overview
A Priority Queue associates each item with a priority and supports efficient access to the next item by priority. It is commonly implemented with a heap.
Stores items so the highest- or lowest-priority item can be removed efficiently.
Compact metadata for implementation and discovery.
A Priority Queue associates each item with a priority and supports efficient access to the next item by priority. It is commonly implemented with a heap.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(log n)
Worst
O(log n)
Space
O(n)
parent(i) = floor((i - 1) / 2)Finds the parent position in an array-backed binary heap.
Show the structure layout and how operations move through or update it.
Priority queues define an abstract operation; heaps are one common implementation.
What each reference supports for this entry.
Textbook reference for the algorithmic family and analysis of Priority Queue.
Good next jumps from the relationship graph, ranked for useful discovery.
Pathfinding · Foundation
Dijkstra implementations use a priority queue for tentative distances.
Compare with thisPathfinding · Core
A* commonly uses a priority queue ordered by f-score.
Compare with thisScheduling · Core
A max-priority queue removes the longest job from an overloaded prefix.
Compare with thisA* commonly uses a priority queue ordered by f-score.
Dijkstra implementations use a priority queue for tentative distances.
Prim's Algorithm commonly stores candidate edges in a priority queue.