Training Quantum Physics Quantum Computing Algorithms
3 / 3

Quantum Computing Algorithms

15 min Quantum Physics

Quantum Computing Algorithms

Quantum computers exploit superposition and entanglement to solve certain problems dramatically faster than any classical computer. Two of the most celebrated algorithms are Grover's search and the Quantum Fourier Transform (the backbone of Shor's factoring algorithm).

Grover's Search Algorithm

To find one marked item in an unsorted database of $N$ items, a classical computer needs $O(N/2)$ queries on average. Grover's algorithm needs only $O(\sqrt{N})$ queries — a quadratic speedup.

Grover Iteration

Starting with the uniform superposition, each iteration ("oracle + diffusion") rotates the amplitude toward the target state by angle $2\theta$ where $\sin\theta = 1/\sqrt{N}$:

$$P(\text{success after }k\text{ iterations}) = \sin^2\!\bigl((2k+1)\theta\bigr)$$

The optimal number of iterations is $k^* = \lfloor\frac{\pi}{4\theta}\rfloor \approx \frac{\pi}{4}\sqrt{N}$.

Interactive Explorer: Grover's Search
Target amplitude = 0.9952
Success probability = 99.0 %
Optimal iterations = 6
Speedup vs classical = 4.6 ×

Quantum Fourier Transform

The QFT maps computational basis states to Fourier-transformed states:

$$\text{QFT}|x\rangle = \frac{1}{\sqrt{N}} \sum_{k=0}^{N-1} e^{2\pi i \cdot xk/N} |k\rangle$$

Unlike the classical FFT which takes $O(N\log N)$ operations, the QFT acts on an $n$-qubit register with only $O(n^2)$ gates — exponentially faster. It is the key subroutine in Shor's factoring algorithm.

Interactive Explorer: Quantum Fourier Transform
N = 2ⁿ = 8
Period = N/A
Factoring hint = Set x≠1

Quantum Speedup Comparison

The power of quantum algorithms becomes clear when comparing their scaling to classical algorithms for large $N$:

AlgorithmProblemComplexity
Brute forceSearch / trial division$O(N)$
FFTDiscrete Fourier transform$O(N\log N)$
GroverUnstructured search$O(\sqrt{N})$
ShorInteger factoring$O((\log N)^3)$
Interactive Explorer: Algorithm Scaling Comparison
Brute force O(N) = 1,000
FFT O(N log N) = 9,966
Grover O(√N) = 31.6
Shor O(log³N) = 1000