cs-089 — The Coin Conjecture
| Field | Value |
|---|---|
| id | cs-089 |
| difficulty | Beginner |
| topics | greedy, counterexamples |
| lecture | lecture-23 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | none |
| objective | state inputs, outputs, and assumptions, then solve a small instance by hand |
| solution | held by the instructor; discussed after the attempt |
Problem
Greedy coin change works for one coin system and fails for another. Find the failing case, explain why, and state when greedy is safe.
Your deliverable is the greedy choice justified with an exchange argument, the counterexample attempt that fails to break it, and the answer for the worked instance. 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: coins {1, 5, 10, 25} for 87 -> greedy 25x3+10x1+1x2 = 6 coins; system {1, 3, 4} for 6 -> greedy 4+1+1 = 3, optimal 3+3 = 2
- Output: greedy optimal for the first system; FAILS for the second - one counterexample kills the claim
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
- Greedy is a hypothesis, not a theorem. Hunt for the smallest counterexample before trusting it.
- 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: "Where does the memory go in the memoised version, and what is the trade?"
Constraints and assumptions
- Difficulty: Beginner (no prior experience assumed).
- Topics: greedy, counterexamples.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for a first attempt; partial answers with clear reasoning are worth more than silent struggling.
- 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.