cs-114 — The Queue Waiting Game
| Field | Value |
|---|---|
| id | cs-114 |
| difficulty | Foundational |
| topics | simulation, queues |
| lecture | lecture-29 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | lectures 1-2 (problem framing, precise pseudocode) |
| objective | recognise the pattern, translate it into precise steps, and trace it correctly |
| solution | held by the instructor; discussed after the attempt |
Problem
One server, random arrivals: simulate waits under different arrival rates. See queueing behaviour emerge; locate the collapse point.
Your deliverable is the simulation result with trials and spread, the one-trial story, and the comparison with exact reasoning. If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.
Examples
- Input: arrivals Poisson-ish rate 4/hour, service 5/hour, simulate 400 hours
- Output: low waits at rho=0.8; collapse as rate approaches service capacity - queues are nonlinear
Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.
What to notice
- Simulate minute by minute: arrival with prob rate/60, service finishes with prob srv/60. Plot (or tabulate) the average wait.
- A simulation is only as good as the story of one trial.
- Error shrinks like 1/sqrt(trials) — quadruple the work, halve the error.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "What hidden assumption did the generator make, and when would it fail?"
Constraints and assumptions
- Difficulty: Foundational (early-semester techniques assumed: precise statements, traces, simple loops).
- Topics: simulation, queues.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes; naming the pattern and stating the assumption is already a pass, completing the calculation is the stretch.
- Optional stretch (not required): describe an alternative approach and say when it beats the obvious one.
Hints and extension
- First nudge: identify the pattern the worked instance uses before computing anything.
- If stuck after three minutes, write the input/output line you expect and trace the smallest example by hand.
- After the reveal, attempt the extension below before the next lecture.
- Extension challenge: Halve and double the trial count; report how the estimate wobbles.