Grover with more than one correct answer

What changes when several items are marked: a bigger starting angle, fewer iterations, and a trap when half the items are correct.

6 min read · reviewed December 2026

More answers mean a bigger angle

With M marked items the starting angle is θ = arcsin(√(M/N)), which is larger than for a single item. A larger angle means each iteration covers more ground, but the quarter turn is the same, so fewer iterations are needed. The optimal count falls from about (π/4)√N to about (π/4)√(N/M).

The measurement returns one of the marked items, and each marked item is equally likely. If you need all of them, you must repeat the run and collect different answers.

Four items, two of them marked

Here θ = 45° (π/4). Zero iterations already give 50 percent, because half the items are correct. One iteration gives 50 percent again. The state rotates by 90 degrees and lands on the mirror image. Grover’s algorithm cannot help when exactly half the items are correct, because the rotation lands the state where it began.

N = 4 items, 2 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
050.0%best count
150.0%overshoot
250.0%overshoot
350.0%overshoot

Eight items, four marked

This is the same trap as above on a larger search space. The lab will tell you when you are in this situation.

N = 8 items, 4 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
050.0%best count
150.0%overshoot
250.0%overshoot
350.0%overshoot

The fix

If M is N/2 or more, a classical guess already succeeds half the time or more, so no quantum help is needed. If you want to use the algorithm anyway, a common trick is to add one extra qubit that doubles the search space while keeping M fixed. The solution fraction becomes M/(2N), the angle is smaller, and the algorithm works normally.

Example: M = N/4

When exactly a quarter of the items are marked, θ = 30° and one iteration gives exactly 100 percent. This is the same arithmetic as the N = 4 case with one answer.

N = 16 items, 4 marked. Exact values from sin²((2k + 1)θ).
Iterations kChance of a marked resultNote
025.0%plain guess
1100.0%best count
225.0%overshoot
325.0%overshoot

Try it

Questions

Does the algorithm return all the marked items?

No. Each run returns one marked item, chosen at random. You need several runs to collect several.

What if I mark every item?

The oracle then flips the sign of everything, which is a global phase with no effect. Every measurement result is correct, so no algorithm is needed.

Read next

Sources and further reading