← Atlas

Algorithms · Quantum query algorithm

Bernstein–Vazirani hidden-string circuit

A query circuit that recovers the hidden bit string in f(x) = s · x.

Strong empiricalUpdated

View frozen graph

A small worked example, computed in your browser. It is not a result from this record's papers.

Bernstein-Vazirani recovers a secret string

4 input qubits, secret string 1011, recovered in a single query.

q0q1q2q3q4Step 1 of 6 · XXStep 2 of 6 · Hadamard layer(5)Hadamard layer(5)Step 3 of 6 · BV oracle(1011)BV oracle(1011)Step 4 of 6 · Hadamard layer(4)Hadamard layer(4)Step 5 of 6 · HHStep 6 of 6 · XX

Step 1 of 6 · X

Probability of each outcome after this step

  • 10000100%
  1. Sets the ancilla to |1⟩, so the next step can put it into |−⟩.

    The whole state moves from 00000 to 10000 — one certain outcome before, one certain outcome after, no superposition either side.

  2. Hadamards everything: the ancilla becomes |−⟩, and the four input qubits spread into an equal superposition.

    Probability spreads from 1 outcome to 32. All 32 are equally likely.

  3. CXs the input qubits where the secret has a 1 (positions 0, 1 and 3) onto the ancilla, kicking back a phase that encodes the secret.

    The outcome probabilities do not move at all. What this step changes is phase — 2 distinct relative phases across the state now — which no measurement can see until a later step turns it back into probability.

  4. A second Hadamard layer on the inputs turns that phase pattern directly into the secret string.

    Probability gathers from 32 outcomes onto 2. 01011 goes from 3.1% to 50.0%.

  5. Undoes the ancilla's Hadamard.

    Probability gathers from 2 outcomes onto 1. 11011 goes from 50.0% to 100.0%.

  6. Returns the ancilla to |0⟩, purely for a tidy final state.

    The whole state moves from 11011 to 01011 — one certain outcome before, one certain outcome after, no superposition either side.

Readout The four input qubits read 1011, the secret, recovered exactly, in one shot. The ancilla reads 0.

Open in Studio
  • Steps3
  • Wires4
  • Qubitsn + 1
  • Depthoracle-dependent
  • Queries1
  • Papers1

Nobody has reviewed this record for gaps yet.

References

Strong empirical
  • Verified by construction
  • Textbook / standard citation
Method
Construct a parity oracle for a fixed secret string and inspect the Deutsch–Jozsa-style readout.
Result
The ideal circuit returns the encoded secret string with one oracle query.
Caveat
The one-query claim is for the promise/query model; state preparation, oracle construction, and readout costs remain visible.
Quantum Complexity Theory ↗
Kind
curated reference
Reviewed by
Leona Quantum curation pass
License
CC BY 4.0-compatible reference metadata
queryhidden stringoracleQiskit

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.