Before Shor’s algorithm threatened modern cryptography and Grover accelerated database searching, quantum computing was primarily a theoretical curiosity. In 1992, David Deutsch and Richard Jozsa published the first quantum algorithm capable of solving a computational problem with 100% deterministic certainty exponentially faster than any classical deterministic algorithm. Paired with Ethan Bernstein and Umesh Vazirani’s 1997 algorithm for parity learning, the Deutsch-Jozsa and Bernstein-Vazirani algorithms established the fundamental operating paradigm of all subsequent quantum software: exploiting Phase Kickback to transform unseen function evaluations into global constructive and destructive interference patterns.
1. The Deutsch-Jozsa Oracle Problem
Consider a boolean black-box function (an oracle) $f: {0, 1}^n to {0, 1}$ that takes an $n$-bit binary string and outputs a single bit. We are guaranteed that $f$ belongs strictly to one of two categories:
- Constant: $f(x)$ returns the exact same value ($0$ for all inputs, or $1$ for all inputs).
- Balanced: $f(x)$ returns $0$ for exactly half ($2^{n-1}$) of the inputs and $1$ for the remaining half ($2^{n-1}$).
The Classical Complexity Bound
In the classical deterministic model, an algorithm must evaluate the function on distinct inputs $x_1, x_2, dots$ until it detects an outcome divergence. In the worst-case scenario where the first $2^{n-1}$ inputs all return $0$, the algorithm still cannot distinguish whether the function is constant or balanced until it queries input number $2^{n-1} + 1$. The classical deterministic query complexity is therefore:
$$Q_{text{classical}} = 2^{n-1} + 1 quad text{evaluations}$$
For $n = 64$ bits, this requires more than $9 times 10^{18}$ queries—rendering classical certainty physically impossible.
2. Phase Kickback: The Core Quantum Mechanism
To evaluate a classical function $f(x)$ reversibly on a quantum computer, we construct a unitary oracle $U_f$ acting on an $n$-qubit input register and a 1-qubit target ancilla:
$$U_f |xrangle |yrangle = |xrangle |y oplus f(x)rangle$$
Suppose the target qubit is initialized in the superposition state $|-rangle = frac{|0rangle – |1rangle}{sqrt{2}}$. Applying $U_f$ yields:
$$U_f |xrangle |-rangle = |xrangle frac{|0 oplus f(x)rangle – |1 oplus f(x)rangle}{sqrt{2}}$$
- If $f(x) = 0$: $|xrangle frac{|0rangle – |1rangle}{sqrt{2}} = |xrangle |-rangle = (+1) |xrangle |-rangle$
- If $f(x) = 1$: $|xrangle frac{|1rangle – |0rangle}{sqrt{2}} = -|xrangle |-rangle = (-1) |xrangle |-rangle$
Combining both cases into a single mathematical expression reveals Phase Kickback:
$$U_f |xrangle |-rangle = (-1)^{f(x)} |xrangle |-rangle$$
The target qubit remains completely unchanged, but the value of $f(x)$ has been kicked up into the global quantum phase of the input register state!
3. The Deutsch-Jozsa Algorithm Execution
- Initialization: Prepare $n+1$ qubits in state $|0rangle^{otimes n} |1rangle$.
- Superposition: Apply Hadamard transforms to all $n+1$ qubits, creating a uniform superposition across all $2^n$ inputs:
$$|psi_1rangle = H^{otimes n}|0rangle^{otimes n} otimes H|1rangle = frac{1}{sqrt{2^n}}sum_{x in {0,1}^n} |xrangle otimes |-rangle$$ - Oracle Query: Apply $U_f$ once:
$$|psi_2rangle = frac{1}{sqrt{2^n}}sum_{x in {0,1}^n} (-1)^{f(x)} |xrangle otimes |-rangle$$ - Interference Transform: Discard the ancilla $|-rangle$ and apply $H^{otimes n}$ to the input register. Using the Hadamard expansion $H^{otimes n}|xrangle = frac{1}{sqrt{2^n}}sum_{z} (-1)^{x cdot z}|zrangle$:
$$|psi_3rangle = frac{1}{2^n} sum_{z in {0,1}^n} left( sum_{x in {0,1}^n} (-1)^{x cdot z + f(x)} right) |zrangle$$ - Measurement: Measure the input register in the computational basis.
The Interference Collapse
Look at the amplitude of the all-zero state $|z = 00dots 0rangle$ where $x cdot z = 0$:
$$alpha_0 = frac{1}{2^n} sum_{x in {0,1}^n} (-1)^{f(x)}$$
- If $f$ is Constant: All $(-1)^{f(x)}$ terms have identical sign. The sum is $pm 2^n$. The amplitude is $alpha_0 = pm 1$. The measurement yields $|00dots 0rangle$ with $100%$ probability.
- If $f$ is Balanced: Exactly half the terms are $+1$ and half are $-1$. The sum cancels completely to $0$ via total destructive interference: $alpha_0 = 0$. The measurement yields any state other than $|00dots 0rangle$ with $100%$ probability.
With exactly 1 single quantum query, the algorithm determines with absolute certainty whether $f$ is constant or balanced!
4. The Bernstein-Vazirani Parity Algorithm
Ethan Bernstein and Umesh Vazirani modified the oracle to find a secret bitstring $s in {0, 1}^n$ where $f(x) = s cdot x pmod 2 = s_1 x_1 oplus dots oplus s_n x_n$.
Classically, extracting $n$ secret bits requires $n$ queries (querying $100dots, 010dots, 001dots$). In the Bernstein-Vazirani algorithm, passing the identical circuit through $U_f$ sets the final state to:
$$|psi_{text{final}}rangle = frac{1}{2^n}sum_z left( sum_x (-1)^{x cdot (z oplus s)} right) |zrangle = |srangle$$
The entire $n$-bit secret string $s$ appears directly in the measurement register in 1 single quantum evaluation, proving unambiguous quantum query superiority.