A lantern needs exactly $2$ charged batteries in order to work.We have available $n$ charged batteries and $n$ uncharged batteries,$n\ge 4$(all batteries look the same). A try consists in introducing two batteries in the lantern and verifying if the lantern works.Prove that we can find a pair of charged batteries in at most $n+2$ tries.
Problem
Source: Danube Mathematical Competition 2015,Juniors #5
Tags: combinatorics
31.10.2015 22:27
This can be solved by using a greedy algorithm and trying to maximize the number of tries at each step. Basically look at the worst case scenario.
31.10.2015 22:47
I do not understand what #2 is trying to say, especially since I think this solution might be the only way to do it. Divide the batteries into $n-1$ groups with sizes 3, 3, 2, 2, ..., 2. By pigeonhole, one of the groups has two charged batteries. With the exception of the last group, try every pair of batteries in the same group, for a total of \[ 2 \cdot \binom{3}{2} + (n-4) \cdot \binom{2}{2} = n + 2 \]tries. If none of these tries work, the last group we didn't test is the desired pair.
31.10.2015 22:54
Follow up question: Is $n+2$ the least nunber of tries to guarantee a charged pair?
31.10.2015 23:10
Very nice solution MellowMelon.The best I could do was to prove that we can find pair of charged batteries in at most $n+3$ tries .
31.10.2015 23:37
It is not too difficult to show that $n+2$ is the best possible bound. Since the problem allows for "I didn't try this pair but I know it works", this is equivalent to: Let $G$ be a graph with $2n$ vertices and at most $n+2$ edges. Show we can choose an independent set of $n$ vertices. This probably follows from a well-known bound that I don't have a reference for, but it's easy enough to obtain with a greedy algorithm: just keep throwing out the vertices with maximum degree. Another interesting question is that "only possible solution" guess I made. That is, if $G$ is a graph with $2n$ vertices, $n+3$ edges, and no independent set of size $n$, is it isomorphic to the graph of two triangles and $n-3$ disjoint edges? I think the answer is yes, but I haven't worked through all the details.