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 gatesdepth419 views0 saves0 forks0 downloads
1OPENQASM 2.0;
2include "qelib1.inc";
3qreg q[4];
4creg c[3];
5// s = 101
6x q[3];
7h q[0]; h q[1]; h q[2]; h q[3];
8// Oracle for s=101
9cx q[0],q[3];
10cx q[2],q[3];
11h q[0]; h q[1]; h q[2];
12measure q[0] -> c[0];
13measure q[1] -> c[1];
14measure q[2] -> c[2];

Cite this circuit

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