Problem. You have bottles of wine; exactly one is poisoned. A taster who drinks from the poisoned bottle dies after exactly one day (the delay is fixed). You have one day. What is the minimum number of tasters needed to identify the poisoned bottle?
The answer
Binary encoding. Number the bottles . Taster drinks from every bottle whose -th bit is 1. After a day, read the pattern of deaths as a binary number — that is the poisoned bottle’s index.
int tasters = 0;
while ((1 << tasters) < n) tasters++;
// taster i drinks from every bottle b with (b >> i & 1)
// result: index = sum over dead tasters i of (1 << i)For : 10 tasters. For : 20.
The lower bound
Each taster produces one bit of information (dead or alive), so tasters distinguish at most outcomes. To identify one of bottles, , hence .
This is an information-theoretic bound, and it is tight because the binary encoding achieves it. The same argument gives the lower bound for comparison sorting, and the bound for binary search.
Variants
poisoned bottles
Now outcomes must be distinguished, so at least tasters are needed. Achieving it requires non-adaptive group testing designs (superimposed codes); the construction is much harder than the case, and tasters suffice.
Multiple rounds
With rounds and tasters, each taster yields a value in survives all, dies in round 1, …, dies in round — that is outcomes per taster, so :
With 2 days and 3 tasters you can handle 27 bottles instead of 8.
Adaptive testing
If you can wait between tests, binary search uses one taster and days. The trade-off between tasters and time is exactly .
Limited tastings per taster
If each taster may drink from at most bottles, the encoding must use low-weight codewords — a combinatorial design problem.
The general principle: information theory as a lower bound
| Problem | Outcomes | Bound |
|---|---|---|
| Poisoned wine, 1 poison | tasters | |
| Comparison sorting | comparisons | |
| Binary search | comparisons | |
| Finding a counterfeit coin (balance: 3 outcomes) | weighings | |
| Guessing a number with yes/no | ||
| Mastermind | ||
| 20 questions |
The counterfeit-coin problem is the classic three-outcome instance: a balance scale gives left, right, or equal, so weighings suffice to find a fake among coins (and if you must also determine whether it is heavy or light).
Why it is worth knowing
Two transferable ideas:
- Encode the answer in binary and let each test read one bit. This solves a whole family of “minimum number of parallel tests” problems.
- Count the outcomes to get a lower bound. Whenever a problem asks “what is the minimum number of queries”, the information-theoretic bound is the first thing to compute — and it is very often achievable.
See also: Binary Search · Entropy · Complexity Theory