Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Quantum information foundations

What makes Bernstein-Vazirani an instructive speedup without making it a universal search engine?

The hidden string appears through a promised oracle

Source research checked . Teaching calculations are ideal models.

The oracle computes the parity of a secret bit string s with an input x. Choose s=1011 and four input bits. The task is to identify s through calls to this specified oracle. It is not a model of opening arbitrary files or searching a database without accounting for how the oracle is built.

The algorithm’s compactness comes from the promise: all responses follow one linear parity rule. Removing that structure changes the problem. The reader should see the cancellation explicitly rather than accept “quantum parallelism” as a complete explanation. A four-bit case is small enough to enumerate every input and verify every sign.

Figure and table scope: Display all sixteen four-bit outputs for the fixed parity mask s=1011 and the ideal Bernstein–Vazirani oracle.

Derivation step 1: Prepare the input register in an equal superposition of every x and an auxiliary target in minus. The oracle’s output flip becomes a phase (-1)^(s·x).

Derivation step 2: Apply a Hadamard to every input qubit. The amplitude of a candidate output y is the average of (-1)^((s⊕y)·x) over all x.

Derivation step 3: When y=s, every term equals one. When y differs from s in at least one position, terms pair off with opposite signs and sum to zero.

Derivation step 4: The ideal output is therefore 1011 in the stated register order. Oracle construction and control accuracy are outside this query-count derivation.

Separate challenge: For candidate y=1001 and secret s=1011, identify a bit position that makes the phase sum cancel.

Worked challenge answer: The strings differ in the third position when written left to right. Pair each x with the x obtained by flipping that position. Their exponents differ by one, so their contributions have opposite signs. All sixteen terms cancel in eight pairs.

Synthetic decision model

Start with the assumptions

  • Exact parity promise, coherent oracle access, no noise and a declared bit order. The count is oracle queries, not a complete end-to-end runtime benchmark.

P(y=s)=1; P(y≠s)=0 under the exact parity promise.

The parity promise singles out the hidden string. Four-bit output versus Probability. Original ideal teaching calculation. Not measured hardware data.
Display all sixteen four-bit outputs for the fixed parity mask s=1011 and the ideal Bernstein–Vazirani oracle. Original ideal teaching calculation. Not measured hardware data.

Compare the input regimes

Each case uses invented inputs. The results follow from this model and do not describe measured hardware.

Reference example with separately scoped figure
Complete inputs
reference scenario
Let s=1011 and f(x)=s dot x modulo two. Compute the ideal final state after Hadamards, a phase oracle and Hadamards.
separate figure scope
Display all sixteen four-bit outputs for the fixed parity mask s=1011 and the ideal Bernstein–Vazirani oracle.
  1. Amplitude of output y = 2^(-n) sum_x (-1)^[(s xor y) dot x]. This equals 1 for y=s and 0 otherwise.
Reference example with separately scoped figure · synthetic calculated results
ReferencePrediction
Original declared exampleFor four input qubits the output is 1011 with certainty in the ideal promised setting. Classical single-position queries return the four mask bits separately.
Separate figure table: Display all sixteen four-bit outputs for the fixed parity mask s=1011 and the ideal Bernstein–Vazirani oracle.
Decoded integer (four-bit output)Ideal output
00
10
30
50
70
90
111
130
150

The declared reference example predicts: For four input qubits the output is 1011 with certainty in the ideal promised setting. Classical single-position queries return the four mask bits separately.

Try the reasoning: For candidate y=1001 and secret s=1011, identify a bit position that makes the phase sum cancel.

Sources and model boundaries

Back to this lab in the catalog