What Makes a Quantum Algorithm?
Quantum Advantage and Where It Comes From
A quantum algorithm achieves an advantage not by running on faster hardware, but by exploiting superposition, entanglement, and interference in ways classical algorithms cannot. The algorithm is designed so that amplitudes corresponding to wrong answers interfere destructively and cancel out, while amplitudes for correct answers interfere constructively and grow.
Not all problems benefit from quantum computation. The complexity class BQP (Bounded-error Quantum Polynomial time) describes problems a quantum computer can solve efficiently. It is widely believed that BQP does not contain all of NP — meaning quantum computers are not a general solution to hard combinatorial problems like the travelling salesman problem.
Grover's Search Algorithm
Grover's Search Algorithm
Unstructured Database Search
Problem: Find a marked item among N unsorted entries.
Classical cost: O(N) — on average, half the database must be checked before finding the target.
Quantum cost: O(√N) — a quadratic speedup. This is provably optimal for unstructured search.
Algorithm steps:
1. Apply Hadamard gates to all qubits, creating an equal superposition of all N states.
2. Apply the oracle Uf, which flips the phase of the target state: |x⟩ → −|x⟩.
3. Apply the diffusion operator (inversion about the mean): amplifies the target's amplitude at the expense of all others.
4. Repeat steps 2–3 approximately π√N / 4 times, then measure to obtain the target with high probability.
Applications: Cryptographic key search, constraint satisfaction, database queries, and as a subroutine in other quantum algorithms.
Shor's Factoring Algorithm
Integer Factorisation
Problem: Given an integer N, find its prime factors.
Classical cost: Sub-exponential — the General Number Field Sieve runs in roughly O(exp((log N)^⅓)). For RSA-2048, this is computationally infeasible in any reasonable timeframe.
Quantum cost: O((log N)³) — polynomial. Exponentially faster than the best known classical algorithm.
How it works: Shor reduces the factoring problem to period finding — discovering the period r of the function f(x) = aˣ mod N. The Quantum Fourier Transform (QFT) efficiently extracts this period from a superposition of values. Once r is known, the factors of N follow from classical number theory (Euclid's algorithm).
Cryptographic significance: Shor's algorithm breaks RSA, Diffie-Hellman, and elliptic curve cryptography — the foundations of today's internet security. This is the primary driver of the post-quantum cryptography movement.
The Quantum Fourier Transform
Quantum vs Classical Complexity