Quantum Algorithm Paradigms
Quantum algorithms achieve speedups over classical algorithms through three main mechanisms:
- Quantum parallelism β superposition allows evaluating a function on all inputs simultaneously
- Interference β amplifying correct answers while canceling wrong ones
- Entanglement β correlating qubits to encode global properties
The most significant speedups come from algorithms using the quantum Fourier transform (QFT) as a subroutine.
The three mechanisms are not interchangeable, and the distinction decides which problems are worth attacking. Parallelism alone buys nothing: a superposition evaluated by holds every at once, but a measurement returns one random with its value, exactly as a classical random query would. Interference is what extracts global structure β Simon's algorithm and Shor's algorithm both arrange phases so that the Fourier transform converts period information into measurement peaks. Entanglement matters where a global property cannot be written as a sum of single-qubit properties, which is why circuit simulation and ground-state estimation keep entanglement in view rather than treating it as decoration.
Deutsch-Jozsa Algorithm
The Deutsch-Jozsa algorithm determines whether a Boolean function is constant or balanced with a single query, whereas a classical algorithm requires queries in the worst case.
Algorithm Steps
- Prepare qubits in and one ancilla in
- Apply Hadamard to all qubits
- Apply the oracle (phase oracle)
- Apply Hadamard to the first qubits
- Measure the first qubits
The output is if is constant, and a non-zero state if is balanced.
The classical comparison is worth stating precisely, because "one query" is often oversold. A deterministic classical algorithm needs queries only in the worst case β the adversary may hide the one input that flips the answer until the last query. A classical algorithm allowed a bounded error rate needs only one query with probability 3/4, by sampling a single random input and predicting "balanced" on a hit. Deutsch-Jozsa therefore separates quantum from deterministic classical, not from bounded-error classical; the first exponential separation from bounded-error classical computation came with Simon's algorithm, and the first from problems people cared about came with Shor.
Simon's Algorithm
Simon's algorithm finds a hidden period of a function where:
Classically, this requires queries (birthday paradox). Simon's algorithm uses only queries.
Key Insight
The quantum circuit uses the same structure as Shor's algorithm. By measuring the output of in superposition and applying the QFT, we obtain linearly independent equations modulo 2 that determine .
The resource count closes exactly. The quantum side produces a uniformly random satisfying , one equation per query, and independent equations determine the single nonzero kernel vector with certainty. So queries plus one verification query suffice, against the classical bound from the birthday paradox. Simon's algorithm is also the proof that Deutsch-Jozsa was not a fluke: the exponential separation survives bounded-error classical algorithms, and the phase-kickback-plus-Fourier pattern it introduces is the skeleton of Shor's period finding a few years later.
Speedup Hierarchy
| Problem | Classical | Quantum | Speedup |
|---|---|---|---|
| Unstructured search (size ) | worst case | quadratic | |
| Factoring ( bits) | with QFT | super-polynomial | |
| Hamiltonian simulation ( qubits) | exponential | ||
| Linear systems (, condition ) | exponential in | ||
| Deutsch-Jozsa | deterministic | 1 | exponential |
| Simon's hidden period | exponential |
Two entries in that table need footnotes before they are quoted. The linear-systems row counts queries to a sparse oracle and ignores how the answer is read out β extracting all amplitudes costs shots, so the useful speedup is limited to expectation values or other few-observable questions. And the simulation row compares against a dense statevector; a tensor network keeps a low-entanglement state compact in time and space, which is why the interesting simulation targets are states whose entanglement entropy grows with system size rather than qubit count alone.
Python: Simon's Algorithm, Structure and Recovery
The hidden-period structure is directly inspectable, and the recovery step is linear algebra over GF(2) rather than anything quantum-mechanical:
import numpy as np
def gf2_rref(M):
# Row-reduce a matrix over GF(2), returning pivots used.
M = M.copy() % 2
rows, cols = M.shape
r, pivots = 0, []
for c in range(cols):
piv = next((i for i in range(r, rows) if M[i, c]), None)
if piv is None:
continue
M[[r, piv]] = M[[piv, r]]
for i in range(rows):
if i != r and M[i, c]:
M[i] ^= M[r]
pivots.append(c)
r += 1
return M, pivots
def kernel_vector(rows, n):
# Nonzero kernel vector of the GF(2) system defined by rows.
R, pivots = gf2_rref(np.array(rows, dtype=int))
free = next(c for c in range(n) if c not in pivots)
s = np.zeros(n, dtype=int)
s[free] = 1
for i, c in enumerate(pivots):
s[c] = R[i, free]
return s
def bits(y, n):
return [(y >> k) & 1 for k in range(n)]
def dot(a, b):
return int(np.dot(a, b)) % 2
rng = np.random.default_rng(11)
n = 4
while True: # oracle f(x) = M x with a one-dimensional kernel
M = rng.integers(0, 2, size=(n, n))
_, pivots = gf2_rref(M)
if len(pivots) == n - 1:
break
def f(x):
b = np.array(bits(x, n))
y = 0
for j in range(n):
if int(M[j] @ b) % 2:
y |= 1 << j
return y
s_true = kernel_vector(M, n)
zeroes = [x for x in range(2 ** n) if f(x) == 0]
print(f"f(x)=0 on {[format(z, '04b') for z in zeroes]}")
measured = []
while len(measured) < n - 1: # what the circuit measures: y with y . s = 0
y = int(rng.integers(0, 2 ** n))
if dot(bits(y, n), s_true) == 0 and y not in measured:
measured.append(y)
s_rec = kernel_vector([bits(y, n) for y in measured], n)
print(f"measured y: {[format(y, '04b') for y in measured]}")
print(f"recovered s = {format(int(s_rec @ (1 << np.arange(n))), '04b')}, "
f"match = {np.array_equal(s_rec, s_true)}")
With seed 11 the oracle vanishes exactly on 0000 and 1111, so the period is 1111. Three sampled measurements β 1111, 0101, 1001 β each satisfy , and the GF(2) solve returns 1111 unchanged. The script evaluates the oracle as a truth table and samples the measurement distribution directly, which is exactly what the phase-kickback circuit produces; the quantum content is not the linear algebra but the fact that queries yield uniform equations in instead of evaluations of .
Quantum Advantage
Quantum advantage (or supremacy) refers to demonstrating a computational task that a quantum computer can solve faster than any classical computer.
In 2019, Google's Sycamore processor performed random circuit sampling in 200 seconds, claiming this would take a classical supercomputer 10,000 years. IBM contested this, estimating 2.5 days with better classical algorithms.
The key criteria for quantum advantage:
- The task must be well-defined and verifiable
- The quantum algorithm must be proven or believed to have no efficient classical simulation
- The quantum computer must actually implement the algorithm correctly
The Sycamore episode supplies the template for reading later claims. The quantum time was measured; the classical time was an estimate made under a stated set of assumptions about memory, disk bandwidth and circuit structure, and those assumptions were revised downward within a year. What survived the argument was the verified sampling task itself β the device did produce samples from a distribution that its builders could simulate at 53 qubits and could not simulate at the full width β and that is the form in which advantage claims are now made: a specific task, a specific device, and a classical baseline with its assumptions listed.
Amplitude Amplification
The amplitude amplification framework generalizes Grover's search. For an algorithm that succeeds with probability , amplitude amplification boosts the success probability to 1 using applications of the Grover operator:
where prepares the initial state and marks the target states.
This provides a quadratic speedup for any algorithm whose success probability is bounded away from zero.
Python: Deutsch-Jozsa Oracle
import numpy as np
def deutsch_jozsa_oracle(n, balanced=True):
# Create a Deutsch-Jozsa oracle as a unitary matrix.
N = 2 ** (n + 1)
oracle = np.zeros((N, N), dtype=complex)
for x in range(2**n):
for y in range(2):
fx = x & 1 if balanced else 0
out = y ^ fx
oracle[out * 2**n + x, y * 2**n + x] = 1
return oracle
# Test with n=2 qubits
n = 2
Uf = deutsch_jozsa_oracle(n, balanced=True)
print(f"Oracle shape: {Uf.shape}")
print(f"Oracle is unitary: {np.allclose(Uf @ Uf.conj().T, np.eye(2**(n+1)))}")
This constructs an oracle for the Deutsch-Jozsa problem and verifies its unitarity.
Quantum Lower Bounds
The quantum query complexity lower bound for unstructured search:
This was proven by Bennett, Bernstein, Brassard, and Vazirani (1997) using the polynomial method and adversary method.
The polynomial method: any quantum algorithm computing with queries produces a polynomial of degree approximating . Since some functions require high-degree polynomial approximation, must be large.
The adversary method: constructs an adversary strategy that forces any quantum algorithm to make many queries.
The two methods are the same tool seen from different angles, and the general adversary bound of Reichardt, Ε palek and others is now known to characterise quantum query complexity exactly β it matches the polynomial method up to constants and closes the question of what a query buys. The practical consequence is a clean dividing line for algorithm design: anything with a provable lower bound is a search-shaped problem and can be met with amplitude amplification, while anything below that bound must exploit structure β algebra, geometry, sparsity β rather than just interference.
Anatomy of a Speedup: the Fourier Subroutine
Three of the six rows in the speedup table share one component, and understanding it explains why the algorithms look alike.
The quantum Fourier transform maps the state into , converting phase periodicity into a computational-basis peak. Shor's period finding feeds it a register holding ; the transform concentrates amplitude on values , continued fractions recover , and the circuit runs in gates. Simon's algorithm feeds it a GF(2) phase structure and the transform returns the dual of the hidden subspace. Phase estimation, the HHL linear-solve algorithm and most spectroscopy algorithms run the same ladder with a controlled unitary in place of modular exponentiation.
The cost is modest and worth quoting: an -qubit QFT needs Hadamards and controlled rotations, so 30 qubits cost 465 two-qubit gates for the transform itself. What makes Shor expensive is not the QFT but the modular exponentiation feeding it, which is why factoring resource estimates are dominated by arithmetic rather than by Fourier analysis.
What Fault-Tolerant Factoring Costs
The distance from a toy circuit to breaking RSA is quantified by one well-known estimate. Factoring a 2,048-bit RSA modulus with Shor's algorithm needs roughly 4,099 logical qubits and about 20 million physical qubits β after magic-state distillation, syndrome extraction and routing are accounted for β to finish in around 8 hours. Compare that with today's machines at a few hundred noisy qubits and the shape of the gap becomes concrete: the algorithmic speedup is settled, the open question is purely how long it takes to build two orders of magnitude more hardware with error rates under the surface-code threshold. Every intermediate milestone on that path β error-mitigated simulations, logical-qubit demonstrations at distance 3 and 5, photonic or neutral-atom scaling β is progress toward a resource estimate, not a smaller version of the same attack.
Summary
Quantum algorithms deliver speedups through interference and entanglement rather than through parallelism alone, and the family splits cleanly by mechanism. Deutsch-Jozsa shows single-query constant testing against deterministic classical queries but not against bounded-error classical; Simon's algorithm supplies the first exponential separation from bounded-error classical computation at queries against , by collecting independent equations and solving them over GF(2). Shor turns the same Fourier pattern into factoring, and amplitude amplification delivers the optimal quadratic improvement on unstructured search that the BBBV lower bound makes unavoidable.
The accounting separates algorithm from machine. A 30-qubit QFT is 465 two-qubit gates β cheap β while factoring RSA-2048 needs about 4,099 logical qubits, 20 million physical qubits and 8 hours, with magic-state distillation dominating the bill. Advantage claims must therefore name the task, the device and the classical baseline together, as the Sycamore result taught the field: the quantum side is measured, the classical side is estimated, and only the stated assumptions let the two be compared.
Common Mistakes
Citing Deutsch-Jozsa as an exponential quantum advantage over classical computation
Fix: The 2 to the n minus one plus one query count is for deterministic classical algorithms; a randomised classical algorithm settles the question with one query half the time
Quoting the HHL linear-systems speedup without the readout cost
Fix: Reading all 2 to the n amplitudes costs 2 to the n shots, so the speedup applies only when the quantity of interest is a few expectation values
Treating a published advantage timeline as a hardware roadmap
Fix: RSA-2048 breaking needs about 20 million physical qubits for 8 hours at roughly 4,099 logical qubits; track logical-error demonstrations rather than qubit counts alone
Key Takeaways
- Quantum parallelism alone buys nothing; every exponential speedup in this family comes from interference arranged by a Fourier transform over some hidden structure
- Simon's algorithm returns n independent equations y dot s = 0 from n queries, which a GF(2) row reduction turns into the hidden period, against a classical birthday bound of 2 to the n over 2
- Deutsch-Jozsa separates quantum from deterministic classical only β a single random query already settles the constant-versus-balanced question with bounded error
- The speedup table carries footnotes: linear-systems speedups ignore exponential readout costs, and simulation speedups assume a dense statevector baseline
- Factoring RSA-2048 is estimated at 4,099 logical and 20 million physical qubits over 8 hours, so the algorithmic result is settled and the bottleneck is hardware scale