Priority Queue
A Priority Queue removes elements according to priority rather than insertion time. A normal FIFO queue processes the oldest element first, while a priority queue processes the highest-priority or lowest-priority element first depending on its configuration.
A normal queue follows FIFO.
A priority queue orders elements by priority.
A binary heap is a common implementation.
Heap insertion and removal are typically O(log n).
Peeking at the highest-priority element is typically O(1).
Priority queues are used in scheduling, shortest-path algorithms, and event processing.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience