TransWikia.com

How do I construct the oracle for a general Bernstein-Vazirani circuit?

Quantum Computing Asked by QuantumLearner on August 6, 2021

Say I have a secret of length $n$, $s = |x_{n-1}x_{n-2}…x_0 rangle$. If I want to construct an oracle for this problem would I just insert a CNOT gate on every qubit where the secret’s value is 1? And just do nothing to all of the 0 qubits?

How would I determine the asymptotic complexity of this circuit in its worst-case situation?

One Answer

Yes, that is right. If you think about it, $CNOT|xrangle |srangle = |xrangle|x oplus s rangle $. Thus, giving a secret bitstring $s = s_1 s_2 cdots s_n$ where $s_i in {0,1}$, then whenever $s_i$ is non-zero ($s_i = 1$), performing a CNOT gate between the ancilla qubit and the $ith$ qubit in your input qubits (note that you have $n$ input qubits and one ancilla qubit in your circuit) is equivalent to performing $x_i cdot s_i $.

Thus, everywhere there is a non-zero element in your secret bitstring $s = s_1 s_2 cdots s_n $ you apply a CNOT gate between the ancilla qubit and the $ith$ input qubit. And anywhere the secret bitstring is zero, you don't do anything.


For example: Suppose your secret bitstring is $s = 0110$ then you would have the following circuit.

enter image description here


The worst case scenario is when your secret bitstring is non-zero every where. $s = 111cdots 1$. In such case, you have to perform $n$ CNOT gates. But note that, on a quantum computer, not all the qubits are connected. So you can't just perform CNOT gate between any pair of qubit you pleased, you need to do some swapping.

For instance, look at the qubit layout in ibmq_16_melbourne enter image description here

you can see that qubit 0 is not connected directly to qubit 13. Hence, to perform a CNOT between qubit 0 and 13, you would need to SWAP qubit 13 and 14 first, perform the CNOT, then SWAP it back... so the actual circuit running on current hardware will be longer than what you see on paper.

Correct answer by KAJ226 on August 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP