The image below is the result of finding 4 correct answers from 8 candidates using qiskit. The 4 correct answers I set were 000, 001, 010, 011, but the graph shows the probability is incorrect (the result gives even distribution). Then, I tried on cases with more qubits, and they are all confused on half solution condition. I have no idea about why it occurs.
-
$\begingroup$ You need to give us more details of what you were doing. $\endgroup$– DaftWullieNov 5, 2021 at 9:36
1 Answer
Check out this explanation of Grover's algorithm.
If half the possible strings are solutions, then we start with $|s\rangle$ exactly halfway between the $|\text{solution}\rangle$ vector and the $|\text{not-solution}\rangle$ vector. When we then do the two reflections, we end up with a vector that is $$U_s U_w |s\rangle = \tfrac{1}{\sqrt{2}}(|\text{solution}\rangle - |\text{not-solution}\rangle)$$
i.e. equal chance of measuring a solution or not a solution.
In reality, we don't care about the case where 50% of states are solutions since we can solve this easily via random guessing.