Practice Discrete Math

Algorithms / Priority Queue Patterns

Least You Need to Know: Priority Queues, Scheduling, and Lazy Updates

A priority queue turns a heap into an algorithmic tool: keep many candidates, then repeatedly extract the **currently best** one. This pattern appears in scheduling, event simulation, shortest-path style relaxations, and systems that reinsert improved priorities over time.

The least you need to know

Key notation

extract-min remove candidate with smallest key
stale entry heap record no longer matches newest best-known value
priority key numeric value used to order the queue

Tiny worked example

  • Suppose servers receive jobs with different deadlines or costs.
  • Push each job into a priority queue keyed by the rule the algorithm cares about.
  • Pop the best candidate, process it, and possibly push updated follow-up work.
  • If an old record remains in the heap after an update, discard it when popped instead of trying to edit the heap in place.

Common mistakes

How to recognize this kind of problem

Start practice