cs-090 — The Meeting Room Marathon
| Field | Value |
|---|---|
| id | cs-090 |
| difficulty | Foundational |
| topics | greedy, exchange argument |
| lecture | lecture-23 |
| 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
Choose the most non-overlapping meetings. Sort by end time; argue the choice with an exchange argument. Greedy with a proof-shaped justification.
Your deliverable is the recurrence with base cases, the answer for the worked instance, and the memoised (or tabulated) version. 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: meetings [(0,3), (1,2), (3,5), (4,7), (7,9)]
- Output: max non-overlapping = 4: (1,2), (3,5), (7,9) + one of (0,3)/(4,7) variant -> verify count 4
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
- Sort by END time; take a meeting whenever it starts at/after the last taken end. Justify by exchange argument.
- Trust the recursive call: if f(smaller) is correct, the transition is all you must get right.
- A DP table is the call tree, cached.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "State f(k)'s meaning in words; is your statement precise enough to code from?"
Constraints and assumptions
- Difficulty: Foundational (early-semester techniques assumed: precise statements, traces, simple loops).
- Topics: greedy, exchange argument.
- 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: Try the greedy rule, break it, then repair with dynamic programming.