Deutsch’s Algorithm

qc/algorithms qc/gates

The first concrete proof that a quantum computer can need fewer queries than any classical algorithm. Deutsch’s problem: given a function as a black-box oracle, determine whether is constant () or balanced (). Classically, this needs 2 queries to be certain (evaluate and , compare). Deutsch’s algorithm does it in 1 query.

The oracle and phase kickback

The oracle is a unitary — reversible, since classical generally isn’t. Key insight — phase kickback: if the target qubit is prepared in instead of a computational basis state, applying leaves unchanged but writes into the phase of the query register instead:

This is because flips the target qubit iff , and flipping just gives .

Circuit and derivation

Prepare , apply to both qubits, apply , apply to the first qubit, measure it.

Applying via phase kickback on each branch of the query register’s superposition:

Applying to the first qubit: if , or if . So:

Measuring the first qubit gives exactly: outcome 0 means constant, outcome 1 means balanced — determined with a single call to , using the interference set up by the two Hadamards around it.

Self-Check

  • Could you explain phase kickback — why does acting on change the phase instead of the state?
  • Why does Deutsch’s algorithm need only 1 query when classically you need 2?
  • What would happen to the final measurement outcome if you skipped the first Hadamard layer?