Question
I want to use the Grover-Algorithm to search an unsorted database for an element $x$. Now the question arises, how do I initialize index and value of the database with the qubits?
Example
- Let's say I have $4$ qubits. Thus, $2 ^ 4 = 16$ classical values can be mapped.
- My unsorted database $d$ has the following elements: $d [\text{Value}] = [3,2,0,1]$.
- I want to search for $x = 2_d = 10_b = |10\rangle$.
- My approach: index the database $d$ with $d [(\text{Index, Value})] = [(0,3), (1,2), (2,0), (3,1)]$. Registers $0$ and $1$ for the index and registers $2$ and $3$ for the value. Then apply the Grover-Algorithm only to registers $2$ and $3 (\text{Value})$. Can this be realized? Is there another approach?
What I already implemented (on GitHub)
The "Grover-Algorithm with 2-, 3-, 4-Qubits", but what it does is simple: the bits are initialized with $|0\rangle$, the oracle will mark my solution $x$ (which is just a number like $2_d = 10_b$), the Grover part will increase the probability of the selected element $x$ and decrease all other probabilities and then the qubits are read out by being mapped to the classical bits. We let this process run several times in succession and thus obtain a probability distribution, where the highest probability has our sought element $x$.
The output is always the same as the one marked in the oracle. How can I generate more information from the output, that I do not know at the time when I constructed the oracle?