Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Deutsch–Jozsa Algorithm

The Deutsch–Jozsa algorithm (Deutsch & Jozsa, 1992) was the first quantum algorithm to exhibit an exact exponential separation between quantum and classical deterministic query complexity. It solves a contrived but clean promise problem on a black-box Boolean function in one query to , where any deterministic classical algorithm needs queries in the worst case.

The algorithm is mostly of pedagogical and historical importance — the problem is artificial and randomized classical algorithms solve it in queries with arbitrarily small error — but it is the canonical first exposure to phase kickback, the Hadamard transform, and quantum parallelism. It is the parent of the Bernstein–Vazirani, Simon, and (ultimately) Shor algorithms.

For broader quantum-computing background see the qcfront project; for the complexity-theoretic frame (, , , query complexity) see math/complexity-theory.md (classical side) and misc/quantum-complexity-theory.md (quantum side, including the query / circuit / QTM models used to make the "one query" claim below precise). For the general anatomy of oracle-based quantum algorithms (how the classical becomes the unitary below), see misc/quantum-algorithms.md.

1. The Problem

Let be given as an oracle (black box). We are promised that is one of the following:

  • Constant: for all , or for all .
  • Balanced: on exactly half of the inputs and on the other half.

The task: decide which case we are in, with certainty, using as few oracle queries as possible.

Inputs not satisfying the promise (e.g. that is on a third of the inputs) are outside the problem; the algorithm's behavior on them is unconstrained.

1.1 Classical query complexity

A deterministic classical algorithm must, in the worst case, query on inputs: after queries returning all s the function could still be either constant- or balanced (with all s on the unseen inputs); one more query decides it. So deterministic classical complexity is .

Randomized classical complexity is trivial: query on uniformly random inputs. If is constant, all answers agree; if is balanced, the probability that all agree is . So queries suffice for any constant error . This is the sense in which the Deutsch–Jozsa "exponential speedup" is fragile — it disappears the moment one allows bounded error.

2. Quantum Preliminaries

We work with qubits — unit vectors in — and tensor products thereof.

2.1 The Hadamard gate

The single-qubit Hadamard is the unitary

Compactly, for :

Applied to all qubits in parallel (the Hadamard transform ), this generalizes to

In particular , the uniform superposition over all -bit strings. And is its own inverse: .

2.2 The oracle

The classical function is supplied as a quantum oracle — a unitary

on qubits, with the bitwise XOR. This is the standard reversible embedding of an arbitrary Boolean function into a unitary. We charge one query per use of .

2.3 Phase kickback

Initialize the ancilla qubit in . Then

Two cases:

  • : the bracket is , so the global sign is .
  • : the bracket is , so the global sign is .

The value of has been moved from the value of the ancilla into a relative phase on the data register. This trick — phase kickback — is the engine of essentially every quantum query algorithm.

3. The Algorithm

The circuit has three stages:

|0⟩^⊗n  ── H^⊗n ──┐                ┌── H^⊗n ── measure
                  │      U_f       │
|1⟩    ── H ─────┘                └── (discarded)

Step by step:

  1. Initialize qubits in .
  2. Hadamard everything: apply to obtain
  3. Query the oracle once. By phase kickback,
  4. Hadamard the data register again:
  5. Measure the data register in the computational basis. Output: "constant" iff the outcome is the all-zeros string , else "balanced".

4. Why It Works

Read off the amplitude of in :

Specialize to , where for every :

Now use the promise:

  • constant. Every has the same sign, so , and hence . Measurement returns with probability .
  • balanced. Exactly of the are and exactly are . They cancel: . Measurement returns with probability .

So the rule "constant iff outcome is " is exact — no error probability, no repetition needed. One query, one shot, certain answer.

A useful way to think about step 4: the Hadamard transform interferes the branches of the superposition. Constructive interference at requires the phases to agree (constant case); destructive interference there requires balanced cancellation. Quantum parallelism plus interference is the essential ingredient — neither alone would do it.

5. Worked Example: (Deutsch's Algorithm)

The original Deutsch (1985) algorithm is the special case. There are four functions :

Type
00constant
11constant
01balanced
10balanced

Equivalently, decide (= 0 for constant, 1 for balanced) using one query.

Tracing through with :

After the final Hadamard on the data qubit, the data-register amplitude on is , which is if and if not. Measure: outcome constant, outcome balanced.

6. Query Complexity Comparison

ModelDeutsch–Jozsa queries
Deterministic classical (worst case, tight)
Randomized classical (bounded error )
Quantum (this algorithm) (exact)

So the separation is exponential vs. constant against deterministic classical, but only constant vs. constant against bounded-error randomized classical. This is why Deutsch–Jozsa is rightly called a milestone (first exact super-polynomial quantum-vs-deterministic separation) but rarely called a practical speedup.

The first quantum algorithm to give a super-polynomial separation against bounded-error randomized classical query complexity is Simon's algorithm (1994), which Shor then converted into the polynomial-time factoring algorithm.

7. Historical and Theoretical Significance

  • First exponential quantum separation (against deterministic classical). Established that quantum computation could outperform classical in some provable sense, opening the field.
  • Phase-kickback template. The pattern "encode classical bits as phases via ancilla, then interfere with " recurs in Bernstein–Vazirani (1993), Simon (1994), and the quantum Fourier transform core of Shor (1994).
  • Promise problems matter. The artificial constant-vs-balanced promise is what makes a deterministic separation possible; without the promise, decision problems on are subject to entirely different lower bounds.
  • Limits. Deutsch–Jozsa puts a contrived problem in (exact quantum polynomial time) but not provably outside (it's outside deterministic query complexity, which is a much weaker statement). Whether , , etc. remain open.

References

  • D. Deutsch, Quantum theory, the Church-Turing principle and the universal quantum computer, Proc. R. Soc. A 400, 97 (1985) — the case.
  • D. Deutsch and R. Jozsa, Rapid solution of problems by quantum computation, Proc. R. Soc. A 439, 553 (1992) — the general case.
  • M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information (Cambridge, 2010), §1.4.3 — standard textbook treatment.