Priority Queue Stability
When multiple elements have the same priority, a priority queue does not necessarily preserve their insertion order. If the application requires equal-priority elements to be processed in arrival order, the queue must explicitly implement stable tie-breaking.
A plain heap generally guarantees priority ordering, not FIFO ordering among equal priorities.
A monotonically increasing sequence number provides deterministic FIFO tie-breaking.
The comparison should first use priority and then sequence number.
Stable behavior is important in schedulers, event processing, and fair task execution.
Tie-breaking rules should be explicitly documented because unspecified ordering can create nondeterministic application behavior.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience