Solution:
Strategy for the Detective: Pick a card A and compare against all others except one. If he ever gets a "Yes", that pair works; else the remaining card is consecutive with A. This process takes at most 50 queries.
Strategy for the Magician: We show that it is not always possible to obtain a "Yes" in 50 turns, hence showing that 49 turns are not enough to figure out a consecutive pair. It is enough to conjure a labelling of cards for which denying all 50 inquiries is valid.
Replace 52 by any N>3. Think of the cards as vertices of a complete graph KN. Delete all edges joining vertices which correspond to pairs of cards the Detective inquired about. We will show that deleting any N−2 edges of KN still leaves a graph that admits a path containing all the vertices. Labelling all cards along this path as 1 to N would finish. Several proofs of this claim are possible. We present three of them.
## Proof 1
For any two vertices a and b, since dega+degb≥2(N−1)−(N−2)=N, they share a common neighbour. Hence the graph is connected.
Pick the longest path P:u=u0→u1→⋯→uk=v. All neighbours of u and v must remain within the path, else we could get a longer path. Let u have x neighbours {ui1,ui2,…,uix} with 1=i1<i2<⋯<ix≤k. Let v have y neighbours {uj1,…,ujy}. Since x+y≥n, we see that is=jr+1 for some r and s. Thus there exists i such that u→ui+1 and ui→v are edges. Thus the path is a cycle
C=ui+1→u0→u1⋯→ui→v→uk−1⋯→ui+1
Suppose a vertex w is not in the path P. By connectedness, we have a path P′ from w to some vertex of P. Continue along this path via the cycle C to obtain a path longer than P; contradiction! Thus the graph has a path of length N−1, as desired.
## Proof 2
Pick the longest cycle C=v1→⋯→vk→v1. Note that any vertex w not in the cycle can be incident to no more than 2k of the vertices in it; else there exists i such that wvi and wvi+1 (indices mod k) are edges, so we can put w in to get a longer cycle. Thus our graph is missing at least 21k(N−k) edges. So 2(N−2)≥k(N−k). Clearly k>2 so we see that k∈{N−2,N−1}.
Case 1. k=N−1. Pick the leftover w outside C. Not all edges from w to the cycle are missing (since only N−2 are missing in total), so follow an edge from w to C and continue along C to get a path of length N−1.
Case 2. k=N−2. Pick the leftover a,b outside C. It is clear that both of them have edges to the cycle and ab is also an edge (since k(N−k)=2(N−2) in this case). So starting at a, going to b, to some vertex of C and following along C gives us a path of length N−1.
The proof is complete.
## Proof 3
The idea is to prove the stronger claim by induction on N≥3: a graph on N vertices with (2N−1)+2 edges has a cycle of length N. Deleting the extra edge will give a path of length N−1 through all the vertices.
The base case N=3 is trivial. Suppose it holds for all k≤N, we prove it for N+1. Since N+12(2+(2N))>N−2 we see that some vertex v has degree either N−1 or N.
Case 1. If degree of v is N−1. Then we have an edge e=uv missing among all the edges through v. Delete v along with all the edges through it in the graph. The induced graph has a cycle of length N. Pick two consecutive vertices that are not u, and append v between them.
Case 2. If degree of v is N. Delete v along with all its edges. Add an arbitrarily chosen extra edge to the graph so obtained. By induction hypothesis, this resulting graph has a cycle of length N. If removing the extra edge does not disrupt the cycle, append v anywhere between two consecutive vertices. If it does break the cycle, use v to connect the vertices it joined.
The induction is complete.