circuits / bernstein-vazirani

Bernstein-Vazirani

FEATURED

Finds a hidden binary string s in a single query to f(x) = s·x mod 2.

quantumcomputer.dev
openqasm4q11 gatesdepth 40 views0 saves0 forks0 downloads

Source Code

OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[3];
// s = 101
x q[3];
h q[0]; h q[1]; h q[2]; h q[3];
// Oracle for s=101
cx q[0],q[3];
cx q[2],q[3];
h q[0]; h q[1]; h q[2];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];

Cite this circuit

MIT
quantumcomputer.dev. "Bernstein-Vazirani". quantumcomputer.dev/circuits/bernstein-vazirani. 2026.