Socratic Mirror
Compression Digest
compression/_posts/2015-08-04-priorityqueue.md

Understanding Priority Queues and Heap Data Structures

[Literal] A Priority Queue is a collection where items can be added at any time, but only the item with the highest priority can be removed. [AI Synthesis] This contrasts with a standard queue (FIFO) and a stack (FILO), where removal order is strictly defined by insertion time.
[Literal] Implementations vary: unordered arrays/linked-lists offer O(1) insertion but O(n) removal of the max element. Ordered arrays/linked-lists offer O(1) removal of the max but O(n) insertion.
[Literal] A binary heap provides an efficient O(logN) for both insertion and removal of the highest priority element.

Key points

Patterns / reminders

Sources