The Bernstein-Vazirani problem (1992) is a cousin of Deutsch-Jozsa. It uses almost the same circuit but solves a different promise problem — and it’s arguably a cleaner illustration of how quantum interference extracts structure from an oracle in one query.
The problem
You’re given a function with the promise that
for some fixed, hidden string . Here is the dot product — the bitwise AND followed by a parity check. Your job: find .
Classically, you need queries: each query (where is the th basis string) returns directly. So you read each bit of one at a time — a total of queries.
Quantum: one query.
The algorithm
The circuit is almost identical to Deutsch-Jozsa:
- Prepare qubits in .
- Apply to each qubit.
- Apply the phase oracle: .
- Apply to each qubit.
- Measure.
The punchline: after step 5, you measure with certainty. The hidden string is the measurement outcome. One query, guaranteed.
Why it works
The key identity is about the Hadamard transform on all qubits:
After step 2, we have a uniform superposition. After step 3 (the oracle), the state is:
Now apply :
The inner sum is if (i.e., ), and otherwise. So the final state is exactly . Measure and you read off the hidden string directly.
Why this is beautiful
The same three-step recipe — Hadamard, oracle, Hadamard — reads a hidden string in one query. It feels almost like cheating. Classically, you’d query , , etc., one bit at a time. Quantumly, the oracle acts on the full superposition at once, the phases it stamps encode the entire bitstring, and the final Hadamard layer transforms those phases into a single definite basis state — the hidden .
The core mechanism behind all of the “Hadamard-oracle-Hadamard” algorithms (Deutsch-Jozsa, Bernstein-Vazirani, Simon’s) is the same:
- Hadamards create a uniform superposition.
- The oracle stamps phases onto the superposition, encoding the information about as a phase pattern across all basis states.
- Hadamards (or the quantum Fourier transform, for Simon’s) convert the phase pattern into a position pattern — a specific basis state that, when measured, reveals the hidden structure.
This “phase pattern → position pattern” is a recurring theme. Grover’s search, Shor’s algorithm, and the quantum Fourier transform all use variations of it.
What’s next
Simon’s algorithm applies the same recipe to find a hidden period — and crucially, its quantum speedup is exponential even against randomized classical algorithms. That’s a hint that some quantum speedups are genuine, not just artifacts of insisting on zero error.