Scaling Up: Deutsch–Jozsa
Deutsch's original algorithm solved a one-bit problem: is a function constant or balanced? The Deutsch–Jozsa algorithm, developed by David Deutsch and Richard Jozsa in 1992, lifts that result to input bits — and the quantum advantage becomes exponential.
The generalized problem
We have a black-box function that is promised to be either:
- Constant: for all , or for all .
- Balanced: for exactly half of the inputs, and for the other half.
Classically, in the worst case you must evaluate at different inputs before you can be certain of the answer — the first half of the inputs could all return the same value, and only the -th query guarantees a conclusion. The Deutsch–Jozsa algorithm answers the question with a single oracle query, regardless of .
The circuit
The algorithm uses input qubits (initialized to ) and one ancilla qubit (initialized to ). The steps are:
- Apply to the ancilla to prepare it in .
- Apply to all input qubits, creating the uniform superposition .
- Query the oracle once.
- Apply to the input qubits again.
- Measure the input qubits.
If the measurement yields (all zeros), the function is constant; any other outcome means it is balanced.
Why it works
After the second layer of Hadamards, the amplitude for the all-zeros outcome is
If is constant, every term has the same sign, so all terms add constructively and the amplitude equals — measuring all zeros is certain. If is balanced, exactly half the terms contribute and half contribute , so the sum is zero and the all-zeros outcome has probability zero.
The first Hadamard layer spreads the input over all basis states at once (quantum parallelism), the oracle imprints the function value as a phase via the ancilla (phase kickback), and the second Hadamard layer converts that global phase pattern back into a measurable amplitude difference. Interference does all the work in a single pass.
Classical vs quantum query complexity
| Strategy | Queries in worst case | |----------------|-----------------------| | Classical | | | Deutsch–Jozsa | |
This vs separation is exact: there is no classical algorithm that can solve the promised problem with fewer than queries in the worst case, and the quantum algorithm never needs more than one. For , classical worst-case requires queries — more than the estimated atoms in the observable universe; the quantum algorithm still uses exactly one.
Deutsch–Jozsa is often called a "toy" algorithm because the promise (constant or balanced) makes the problem somewhat artificial. Its real value is didactic: it is the cleanest demonstration that quantum parallelism combined with interference can yield an exponential query advantage, and many deeper algorithms — Bernstein–Vazirani, Simon's algorithm, Shor's — inherit exactly this structure.
Sign in on the full site to ask questions and join the discussion.