Deutsch-Jozsa Algorithm

Graduate Depth 128 in the knowledge graph I know this Set as goal
Unlocks 3 downstream topics
Deutsch-Jozsa oracle quantum-speedup quantum-parallelism

Core Idea

The Deutsch-Jozsa algorithm determines whether a Boolean function f:{0,1}^n -> {0,1} is constant (same output for all inputs) or balanced (outputs 0 for exactly half the inputs and 1 for the other half), promised that one of these holds. A classical deterministic algorithm requires 2^(n-1) + 1 queries in the worst case, but the quantum algorithm uses exactly one query to the function oracle. It was the first algorithm to demonstrate a provable exponential separation between quantum and classical deterministic query complexity, establishing that quantum computers can solve certain problems fundamentally faster.

Explainer

The Deutsch-Jozsa algorithm is historically important as the first quantum algorithm to demonstrate an exponential separation from classical computation, even though the problem it solves is artificial. You are given a black-box function f:{0,1}^n -> {0,1} with the promise that f is either constant (all outputs are the same) or balanced (exactly half the outputs are 0 and half are 1). Classically, in the worst case, you must evaluate f on 2^(n-1) + 1 inputs to be certain — you might get unlucky and see the same output for the first 2^(n-1) queries. The quantum algorithm uses one query.

The circuit works as follows. Prepare n input qubits in |0> and one ancilla qubit in |1>. Apply Hadamard to all n+1 qubits. The input register is now in a uniform superposition over all 2^n basis states, and the ancilla is in |-> = (|0> - |1>)/sqrt(2). Apply the oracle Uf, which maps |x>|y> to |x>|y xor f(x)>. Because the ancilla is in |-> , the effect of the oracle is phase kickback: the ancilla stays in |-> and each input state |x> acquires a phase (-1)^f(x). The state is now (1/sqrt(2^n)) * sum_x (-1)^f(x) |x> tensor |-> .

Now apply Hadamard to each input qubit. The Hadamard transform maps the state to a sum over all output basis states, where the amplitude of each output state |y> is a sum involving (-1)^f(x) * (-1)^(x dot y) over all x. The amplitude of |0...0> specifically is (1/2^n) * sum_x (-1)^f(x). If f is constant, this sum is +/- 1, so the probability of measuring |0...0> is 1. If f is balanced, exactly 2^(n-1) terms are +1 and 2^(n-1) are -1, so the sum is zero and the probability of measuring |0...0> is 0. A single measurement therefore determines the answer with certainty.

The key mechanism is interference. The oracle embeds the function's behavior into phases, and the final Hadamard transform recombines these phases. For a constant function, all paths interfere constructively at |0...0>. For a balanced function, they interfere destructively and the amplitude at |0...0> vanishes completely. This pattern — oracle encodes information into phases, followed by interference that concentrates the answer — recurs throughout quantum algorithms. The Deutsch-Jozsa algorithm is the simplest instance of this paradigm. It is worth noting that a probabilistic classical algorithm can solve this problem with O(1) random queries and high confidence, so the exponential advantage is specifically over deterministic classical algorithms. The deeper significance is conceptual: it proves that quantum query complexity can be strictly less than classical.

Practice Questions 3 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsInteger Order of OperationsVariable ExpressionsCombining Like TermsOne-Step EquationsTwo-Step EquationsSolving Multi-Step EquationsEquations with Variables on Both SidesAngle Pairs: Complementary, Supplementary, and VerticalParallel Lines and TransversalsCorresponding AnglesAlternate Interior AnglesTriangle Angle Sum TheoremExterior Angle TheoremTriangle Inequality TheoremSimilar Triangles: AA SimilaritySimilar Triangles: SSS and SAS SimilarityProportions in Similar TrianglesRight Triangle Trigonometry IntroductionTrigonometric Ratios ReviewRadian MeasureConverting Between Degrees and RadiansThe Unit CircleGraphing Sine and CosineGraphing Tangent and Reciprocal Trigonometric FunctionsDerivatives of Trigonometric FunctionsAntiderivativesIterated Integrals and Fubini's TheoremDouble Integrals in Cartesian CoordinatesDouble Integrals over Rectangular RegionsDouble Integrals in Polar CoordinatesDouble Integrals: Definition and SetupIterated Integrals and Fubini's TheoremDouble Integrals over Rectangular RegionsDouble Integrals over General RegionsApplications of Double Integrals: Area, Mass, and MomentsTriple Integrals in Cartesian CoordinatesTriple Integrals in Cylindrical and Spherical CoordinatesChange of Variables and the Jacobian DeterminantApplications of Triple Integrals: Volume and MassVector Fields and Their RepresentationsLine Integrals of Vector FieldsGreen's TheoremSurface Integrals and Flux of Vector FieldsSurface Integrals and Flux of Vector FieldsDivergence Theorem: Flux and OutflowDivergence TheoremElectric FluxGauss's LawConductors in Electrostatic EquilibriumCapacitance and CapacitorsDielectricsDielectric Constant and Relative PermittivityElectric Field Inside Dielectric MaterialsDielectric Materials and PolarizationDielectric Susceptibility and PermittivityEnergy Density in Electric FieldsElectric Current and Current DensityElectrical Resistance and ResistivityOhm's Law and Circuit ElementsElectromotive Force (EMF) and BatteriesKirchhoff's Circuit Laws: Voltage and CurrentDC Circuit Network Analysis MethodsTransient Response in RC CircuitsRC CircuitsLC and RLC CircuitsAC Circuits: FundamentalsImpedance and ReactanceAC Power and ResonanceElectromagnetic WavesThe Electromagnetic SpectrumBlackbody Radiation and Planck's LawPhotoelectric EffectThe Photon: Light as QuantaCompton ScatteringWave-Particle Dualityde Broglie WavelengthHeisenberg Uncertainty PrincipleWavefunction and the Born RuleThe Schrödinger EquationSchrödinger Equation: Time-Dependent FormWavefunctions and Boundary ConditionsBoundary Value Problems in ElectrostaticsParticle in a Box (Infinite Square Well)Quantum NumbersSpin-1/2 SystemsPauli MatricesQuantum GatesQuantum CircuitsDeutsch-Jozsa Algorithm

Longest path: 129 steps · 672 total prerequisite topics

Prerequisites (2)

Leads To (1)