DescriptionQ502
Q502DVASIC interview problem
Enforce a rolling bandwidth limit
TechniquesPythonSliding windowBandwidthDeque
DifficultyMedium
TopicReference Models
LanguagePython
Requirements4 checkpoints
01
Problem
Implement a checker allowing at most five accepted packets in any rolling ten-cycle window.
Example input and output
Use this case to check your interpretationInput
accepted packet cycles=[0,1,2,3,4]; attempt at cycle 9; attempt at cycle 10Output
cycle 9 packet rejected as sixth in the rolling window; cycle 10 packet accepted after cycle 0 expiresExplanation
Before checking cycle 10, events at or before 0 leave the ten-cycle window; the rejected cycle-9 event never pollutes legal state.
02
Requirements (4)
- Accept monotonically nondecreasing cycle numbers.
- Before checking a new packet at cycle c, remove events at or before c - 10.
- Reject a sixth in-window packet without adding the illegal event to legal model state.
- Use cycle counts rather than simulator time units.
