Sign in
← Atlas
Strong empiricalAlgorithmsQuantum query algorithm

Deutsch–Jozsa query circuit

A one-query promise-problem circuit that separates constant from balanced Boolean oracles.

queryoraclephase kickbackCirq

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

Deutsch–Jozsa is a clean record for showing how phase kickback and interference change the query model.

Circuit & simulation
constant50%
balanced50%
What this takes and returns
TakesNothingWhat joins here

No input port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.

Nothing in the Atlas meets this end.

ReturnsNothingWhat joins here

No output port at this edge: the record publishes no gate sequence and no register, so there is nothing here to read one off — and unlike a declared hole, nothing has been recorded about what belongs here.

Nothing in the Atlas meets this end.

This record publishes no gate sequence and no register, so there is nothing here to read an interface off. Absent rather than empty. See all 152 →

How it works

The Deutsch–Jozsa problem promises that f:{0,1}n{0,1}f:\{0,1\}^n\to\{0,1\} is either constant or balanced (outputs 0 and 1 equally often), and asks which. The circuit prepares the output qubit in =12(01)|-\rangle=\frac{1}{\sqrt2}(|0\rangle-|1\rangle) and the input register in Hn0nH^{\otimes n}|0\rangle^{\otimes n}, queries the reversible oracle Uf:xyxyf(x)U_f:|x\rangle|y\rangle\mapsto|x\rangle|y\oplus f(x)\rangle once, and applies HnH^{\otimes n} again to the input register before measuring. Phase kickback turns each query into a sign (1)f(x)(-1)^{f(x)} on x|x\rangle rather than touching the output qubit, and interference across the 2n2^n branches makes the input register collapse to 0n|0\rangle^{\otimes n} exactly when ff is constant, and to a nonzero string when ff is balanced — one query suffices, versus up to 2n1+12^{n-1}+1 classical queries in the worst case for a deterministic algorithm. This record reviews the phase-kickback circuit for a two-bit input against that construction; it stores one small educational oracle instance, not a general-nn benchmark.

Implementation
Native
deutsch_jozsa.py
import cirq

q0, q1, q2 = cirq.LineQubit.range(3)
circuit = cirq.Circuit(
    cirq.X(q2),
    cirq.H(q0), cirq.H(q1), cirq.H(q2),
    cirq.CNOT(q0, q2), cirq.CNOT(q1, q2),
    cirq.H(q0), cirq.H(q1), cirq.H(q2),
    cirq.measure(q0, q1, key='input'),
)

FINAL_CIRCUIT = circuit
Quantum vs classical

Classical baseline

Compare Quantum query algorithm with the strongest classical method for the same instance, input budget, and output metric.

Quantum claim

This reference exposes a quantum circuit pattern; it does not imply an application-level speedup without a matched benchmark.

How to compare

Report input loading, circuit depth, repetitions, classical preprocessing, post-processing, and wall-clock time together.

Declared gaps

Nobody has reviewed this record for gaps yet.

Literature & references
Quantum Computation and Quantum Information: 10th Anniversary Edition2010 · Michael A. Nielsen and Isaac L. Chuang

Standard graduate textbook covering the single- and two-qubit gate definitions, matrix identities, and circuit primitives this record states.

doi.org/10.1017/cbo9780511976667