Compare Fixed and Variable Train Gaps Without a Timetable
DeshawSoftware Engineer · Technical ScreenLast updated
Compare two train services for a commuter who arrives without consulting a timetable. Explain the assumptions and derivation clearly, check edge cases, and show how the result changes when those assumptions no longer hold.
Compare Fixed and Variable Train Gaps Without a Timetable
Compare two train services for a commuter who arrives without consulting a timetable. Service A has a fixed 10-minute gap. Service B repeats gaps of 5, 10, and 15 minutes. Assuming the commuter's arrival time is uniformly distributed over a long operating cycle, compute the expected waiting time for each service and explain which is preferable under this criterion.
Constraints & Assumptions
- Train dwell time is negligible and service repeats indefinitely.
- The commuter arrives independently of the schedule.
- For Service B, each 5-, 10-, and 15-minute interval occurs once per cycle.
- Preference is based only on expected wait, not variance, crowding, or missed connections.
Clarifying Questions to Ask
- Are the variable gaps a deterministic repeating schedule or independent random draws?
- Is the commuter's arrival independent of train arrivals?
- Should the comparison include worst-case waiting time as well as expectation?
Hints
Hint 1
Compare identical mean gaps carefully: Both services average ten minutes between trains; explain why that fact alone may or may not determine a random commuter's wait.
Hint 2
Check the extremes: Relate the short and long gaps to both the best-case and worst-case wait before calculating an expectation.
Follow-up questions
- How do the wait-time variances compare?
- What changes if the 5-, 10-, and 15-minute gaps are chosen with unequal frequencies?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.