How can I construct Deutsch-Jozsa? I know that I need superposition and phase kickback, which means I need to apply Hadamard Gate at the beginning the at the end, I also need to apply an $X$ gate then a Hadamard gate to the auxiliary for phase kickback to properly function. But I'm not sure how to apply the CX gate exactly in a balanced oracle situation?
1 Answer
You have to construct the oracle so that its output is on the auxiliary qubit. At the same time you have to preserve input state of other qubits after the oracle.
For example assume two variable function $f(x_1,x_2)=x_1$. In this case you put control qubit of CNOT on the first qubit of the circuit, second qubit is unchanged and target qubit of CNOT will be on ancilla.
For function $f(x_1,x_2)=\bar{x_1}$ you firstly apply $X$ gate on the first qubit, then CNOT in th same way as above and finally again $X$ gate to preserve input state into the oracle.