# Creating a unitary for binary encoding with respect to already encoded index states

Let us say that there are two quantum registers qr1 and qr2. Now the qr1 is in the state $$\sum_i |x_i\rangle$$(here $$x_i$$ is binary encoded value upto some precision) and originally qr2 is $$|0\rangle$$, the net state is, $$|\psi_0\rangle=\sum_i |x_i\rangle|0\rangle$$

This particular state is passed to an oracle which encodes a value $$y_i$$ with every $$x_i$$ (here we have the list of all the $$x_i$$'s and their corresponding $$y_i$$'s before we start making the oracle). So the final state can be written as,

$$|\psi_1\rangle=\sum_i |x_i\rangle|y_i\rangle$$

What could be an effecient method of making such an oracle. Any literature which takes some similar problem into consideration would also be helpful.

A bad solution that we already have -

Let's say I wanna encode |10> with |110011>(now as there is a superposition over i things I need to make sure that only |110011> gets entangled with |10>), so we apply X gates to the middle two qubits and make the state |111111> now a multi controlled toffoli is used with controls as all the qubits in qr1 and targets with specific qubit in qr2, so basically targeting first qubit in our case. As all the control bits are in one for only the case with |110011> as $$x_i$$ we see that the particular $$y_i$$ is obtained. Finally X gates are again applied to qr1 to make the original state. The circuit can be given as [

but as we do this for a lot of samples our circuit starts to fail

• Isn't this the whole point of qRAM: arxiv.org/abs/0708.1879 ? Feb 22, 2022 at 8:01
• So QRAM actually creates an initial state and we are modifying a state that we already have. Plus this is technically something we have had to do to avoid making a QRAM because a QRAM actually requires much more qubits. A larger depth is still not that big of a problem, but a circuit with large number of qubits is the bigger problem Feb 22, 2022 at 10:27