The Famous Ones

Grover's Search

10 min

You have a phone book with a million entries, shuffled into random order. You know the number you want; you need the name.

The ordinary way, you check entries one at a time. On average, half a million checks.

Grover's method finds it in about 785.

One Grover iteration
after H⊗ⁿafter the oracleafter diffusionbars below the line are negative amplitudes — still probability, but with the opposite sign
Flip the sign of the answer, then reflect every amplitude about the mean. The marked entry grows, the rest shrink. Repeat about (π/4)√N times and stop — going further makes it worse again.

One round, two moves

Mark it. The black box puts a minus sign on the entry you want. Nothing visible has changed yet — the odds are all still identical.

Fold everything about the average. Work out the average of all the amplitudes and reflect every one across it. The marked entry, sitting below the average because it went negative, gets thrown well above it. Everything else drops a little.

Repeat. Each round nudges the right answer up a bit more, and the wrong answers down.

Amplitude amplification

The general version of the trick. Any hit-or-miss procedure can be made near-certain in roughly the square root of the usual number of attempts. Grover is just the case where the procedure is "guess at random".

You have to know when to stop

This is the part that surprises everyone.

Grover is a rotation, and rotations keep going. Do about (π/4)√N rounds and the right answer is nearly certain. Keep going and it rotates straight past — the odds start coming back down.

Run it twice as long as you should and you are worse off than when you started.

Where it helps, and where it does not

Grover needs nothing but a way to check a candidate, so it applies almost everywhere: puzzles, password cracking, database lookups.

Two things take the shine off.

First, this is the ceiling, not the floor. Four researchers proved in the 1990s that no quantum method can ever do unstructured search faster than this. There is no better version coming.

Second, square-rooting a million gives you a thousand — which is lovely, but the overhead of running a real error-corrected quantum computer can swallow the whole gain. Current estimates suggest Grover only beats an ordinary machine on problems so large that neither one finishes.

~785

Rounds needed for a million entries, versus 500,000 checks

Stop!

Run three times too long and your odds fall to around 25%

Proven

No quantum method will ever beat this for unstructured search

Worth remembering

  • Grover finds a marked item in about the square root of the usual number of checks.
  • Each round marks the answer with a minus sign, then folds everything about the average.
  • Overshooting makes your odds worse, so you must stop at the right moment.
  • This speed is a proven ceiling, and overheads often eat the gain in practice.