Algorithms

Grover's Algorithm

A quantum search algorithm that finds a marked item among N possibilities in about the square root of N steps.

Definition

Grover's algorithm is a quantum algorithm, published by Lov Grover in 1996, that searches an unstructured collection of N items for a marked one using about √N queries, where any classical method needs about N. The speed-up is quadratic, and it is provably the best possible for unstructured search.

In depth

The success probability after k iterations is sin²((2k + 1)θ), where θ = arcsin(1/√N). For N = 8 with one marked item, θ ≈ 0.3614 radians. One iteration gives sin²(3θ) = 0.78125, two iterations give sin²(5θ) = 0.9453, and three give sin²(7θ) = 0.3301. The optimum for N = 8 is two iterations, and a third overshoots. These are the numbers you can reproduce in the interactive circuits in our superposition lesson.

The quadratic speed-up has a practical edge to it. A fault-tolerant quantum operation can be thousands or millions of times slower than a classical one, so the quantum machine only wins when the search space is very large. If one Grover iteration takes a millisecond and a classical check takes a nanosecond, the break-even size is about 10¹² items. Our lesson on whether quantum computers will replace classical ones works through the arithmetic.

For cryptography the effect is simple. Searching a 128-bit key space classically takes about 2¹²⁸ trials, and Grover's algorithm takes about 2⁶⁴ iterations, which is why doubling symmetric key lengths, for example using AES-256, is the usual recommended response.

Technical Definition

Starting from a uniform superposition over N basis states, the algorithm repeats two steps: an oracle flips the sign of the marked state's amplitude, and a diffusion operator reflects all amplitudes about their mean. Each repetition rotates the state vector by an angle 2θ toward the marked state, where sin θ = 1/√N. After about (π/4)√N iterations the probability of measuring the marked item is close to 1.

Visual Explanation: An Analogy

Picture a room full of people all holding signs of equal height. A helper flips one person's sign upside down, and then everyone's height is reflected about the average. The upside-down sign now sticks up a little higher than the rest. Repeat the trick and that one sign towers over the others. Stop at the right moment, or the pattern overshoots and shrinks again.

Key facts

ItemDetail
PublishedLov Grover, 1996
Speed-upQuadratic: about (π/4)√N iterations
OptimalProven optimal for unstructured search
N = 8 exampleP = 0.78125 after 1 iteration, 0.9453 after 2, 0.3301 after 3

Where the idea comes from

Lov Grover announced the algorithm in 1996, two years after Shor's. Later work by Bennett, Bernstein, Brassard and Vazirani showed that no quantum algorithm can search an unstructured space with fewer than order √N queries, so Grover's method cannot be improved in general.

Real-World Use Cases

  • Searching unstructured spaces where only a checking function is available
  • Speeding up brute-force attacks on symmetric keys by a quadratic factor
  • Serving as a subroutine in counting and optimisation algorithms

How it differs from related ideas

  • Grover's algorithm gives a quadratic speed-up, while Shor's gives a superpolynomial one on a more structured problem.
  • Classical search can be parallelised across many cores, and Grover's iterations are hard to parallelise, so the practical advantage is smaller than the formula suggests.

Common Misconceptions

  • Grover's algorithm does not make a database search exponentially faster. The gain is quadratic, and loading classical data can erase it.
  • More iterations are not always better. After the optimum the success probability falls again, an effect called overshoot.

Frequently asked questions

How many iterations does Grover's algorithm need?

About (π/4)√N for one marked item. For N = 8 that is two.

Does Grover's algorithm break AES?

It reduces the effective strength of a symmetric key by half in bits, so AES-128 behaves like a 64-bit search and AES-256 like a 128-bit one. That is why AES-256 is the usual recommendation.

What is the oracle?

A circuit that recognises the marked item and flips the sign of its amplitude. Building it efficiently is a major part of any real application.

Related Terms

Learn it in a lesson

← Back to the dictionary