cs-084 — The Rotten Timeline
| Field | Value |
|---|---|
| id | cs-084 |
| difficulty | Expert |
| topics | binary search, monotonicity |
| lecture | lecture-21 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | the full Block I-III toolbox and proof-shaped reasoning |
| objective | make and justify design decisions where the method itself is the challenge |
| solution | held by the instructor; discussed after the attempt |
Problem
An event switches state once and stays switched (monotone); find when, given a testable 'state at time t'. Generalising binary search to monotone predicates.
Your deliverable is the located answer, the predicate, and the bound updates shown for one full trace. 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: a service is healthy before 14:37 and degraded after; 'state at time t' is testable
- Output: find switch minute with ~log2(minutes) tests; predicate: state(t) == degraded
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
- Monotone predicate = binary search playground, even on time. Half-open bounds keep it clean.
- Binary search is a loop plus a monotone question — nothing more.
- Half-open intervals keep the arithmetic honest.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "State the monotone predicate for this case in one sentence."
Constraints and assumptions
- Difficulty: Expert (independent design decisions and proof-shaped arguments assumed).
- Topics: binary search, monotonicity.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for the attack plan; the full argument may exceed the box - outline the proof strategy instead of grinding details.
- 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: Re-solve the same instance on a monotone predicate instead of an array.