The Bernstein-Vazirani algorithm is a quantum algorithm that solves a specific problem known as the "oracle problem". In this problem, we are given a black-box oracle (a function) that computes a dot product between an unknown binary string "s" and an input binary string "x," modulo 2. The goal is to determine the unknown string "s." The Bernstein-Vazirani quantum circuit uses quantum parallelism to determine the unknown string "s" in a single query to the oracle, whereas a classical algorithm would require multiple queries—one for each bit of "s".
Using
QuantumCircuitOperator[{"BernsteinVazirani",st}]
, one can generate the Bernstein–Vazirani for the given secret string st.
Generate Bernstein–Vazirani circuit for the secret string 101: