Grover’s Algorithm
A quantum search algorithm providing quadratic speedup for finding items in unsorted databases.
Grover’s algorithm (1996) searches an unsorted database of items in queries, compared to classically. It’s one of the foundational quantum algorithms.
The Problem
Given a function that returns 1 for exactly one “marked” item and 0 otherwise, find the marked item.
- Classical: Check items one by one → queries on average
- Quantum (Grover): queries
The Algorithm
Grover’s algorithm repeatedly applies two operations:
1. Oracle
Marks the solution by flipping its sign:
2. Diffusion
Reflects amplitudes about their average (amplitude amplification): where is the uniform superposition.
The Circuit
|0⟩^n ── H^⊗n ──┬── O ── D ──┬── ... ── Measure
│ │
(repeat √N times)
Geometric Intuition
Think of the state as a vector in a 2D plane:
- One axis: the marked state
- Other axis: superposition of unmarked states
Each Grover iteration rotates the state vector toward by angle .
After iterations, the state points at (or very close to) .
Example: N = 4
- 4 items, need to find 1 marked item
- Classical: 2.25 queries on average
- Grover: ~1 iteration (plus setup)
Starting state:
If is marked:
- Oracle:
- Diffusion: (exactly the answer!)
Key Properties
Optimal
Grover’s algorithm is provably optimal. No quantum algorithm can do better than for unstructured search.
Works with Multiple Solutions
If items are marked, the algorithm finds one in queries.
Requires Knowing When to Stop
Over-iterating causes the amplitude to “rotate past” the solution. You need to know approximately how many iterations to run.
Applications
- Database search: Searching unsorted data
- Cryptography: Speed up brute-force attacks (effectively halving key lengths)
- Satisfiability: Search for satisfying assignments
- Amplitude amplification: Generalization used in many algorithms
Practical Considerations
Quadratic speedup is significant but not transformative:
- → queries (meaningful)
- But requires a quantum oracle for , and building this can be expensive
See also: Quantum Algorithm, Quantum Speedup