Grover’s search algorithm, also known as the quantum search algorithm, is a cornerstone of quantum computation, offering a quadratic speedup for unstructured search problems. It was introduced by Lov Kumar Grover in 1996 in his paper A fast quantum mechanical algorithm for database search [arXiv:quant-ph/9605043]. Whereas classical algorithms require queries to search an unsorted database of
elements, Grover’s algorithm achieves the same task with only
queries by exploiting quantum parallelism and amplitude amplification.
Searching an unstructured database is a fundamental task in many practical applications, such as finding the lowest-priced product, determining the shortest path to a destination via transfers, and solving other optimization problems. In this post, we begin with the simplest case of a single marked item and later consider the general case with multiple marked items. The core of Grover’s algorithm is the Grover iteration. The algorithm’s precision depends on the ratio , where
is the number of marked items and
is the total number of items.
Definition.(Unstructured search problem) The goal of Grover’s algorithm is to locate the marked element in an unsorted database. Given an oracle function
where for the marked item
and
for all other items$, the task is to find the marked elements
using fewer oracle queries than would be required classically.
Quantum oracle
To solve this problem quantumly, we also need to introduce a quantum oracle.
Recall that the classical oracle is a function with
for the marked item
and
for all other items.
We can generalize this to a quantum oracle , which is a unitary operation that flips the sign of the amplitude of the marked state:
where corresponds to the binary string
.
This construction is the same as the oracles encountered in the Deutsch–Jozsa and Bernstein–Vazirani algorithms. By introducing an ancillary qubit initialized in the state , we define the oracle
so that
Dropping the ancillary qubit then recovers
In particular, for the marked state ,
, so its phase is flipped:
For all unmarked elements,
, so their amplitudes remain unchanged.
Grover iteration
The algorithm proceeds by repeatedly applying a procedure known as the Grover iteration or Grover operator to amplify the amplitude of the marked state. As we shall see, each Grover iteration corresponds to a rotation within a two-dimensional plane. The rotation angle at each step depends on the ratio between the number of marked items and the total number of items.
Suppose the search space contains items, of which
are marked. Define the states
representing an equal superposition of all unmarked items, and
representing an equal superposition of all marked items.
The uniform superposition over all items,
can be expressed as a superposition of and
:
We assume that is small. In this regime, the coefficient
corresponding to the unmarked states is much larger than the coefficient
associated with the marked states. Consequently, the initial state
is predominantly aligned along
, and the Grover iteration rotates the state vector slowly toward
, allowing gradual amplitude amplification of the marked state.
It is convenient to introduce an angle defined by
This angle quantifies the initial projection of onto the marked subspace and will be useful for understanding Grover iteration geometrically.
Each Grover iteration consists of two main steps:
- Oracle Query (Phase Flip): Apply the oracle
, which flips the phase of the marked state:
. Geometrically, this can be viewed as a reflection about the state
. For any state in the two-dimensional subspace spanned by
and
,
,
the action of the oracle gives,
showing that thecomponent is reflected.
- Amplitude Amplification (Grover Diffusion Operator): Apply the diffusion operator
,
whereis the uniform superposition over all items as defined earlier. This operation can be interpreted as a reflection about
in the plane spanned by
and
. To see this, define
,
whereand
are the coefficients of
in the
,
basis, so that
is orthogonal to
in the plane. Any state in this plane can be expressed as
. Acting with
yields
,
confirming thatperforms a reflection about
.
The combined Grover iteration operator is defined as
.
Within the two-dimensional subspace spanned by and
, consider an initial state
,
whose angle from is
. Applying the oracle
first reflects the state about
, and subsequently applying
reflects the resulting state about
. The composition of these two reflections produces a net rotation by an angle
toward
.
In Grover’s search, the initial state is the uniform superposition , which lies at an angle
from
. Each application of
therefore increases this angle by
, gradually amplifying the amplitude of
and increasing the probability of measuring the marked state.
Exercise. Verify that performs the rotation illustrated in Fig. 2. Show explicitly that the Grover iteration acts as a rotation matrix in the basis
.
From Fig. 2, it is clear that becomes small when the ratio
is small. Consequently, each Grover iteration corresponds to a small but precise rotation, making the algorithm particularly powerful for large databases with relatively few marked items.
Grover’s Search Algorithm
The detailed procedure of Grover’s search algorithm is given below.
1. Initialization
- Prepare
qubits in the state
.
- Apply the Hadamard transform
to obtain the equal superposition
.
2. Grover iterations
Apply the Grover iteration operator for
rounds. Each round consists of:
- Oracle
, flipping the phase of the marked state.
- Diffusion operator
, performing amplitude amplification.
3. Measurement
After approximately iterations, the amplitude of the marked state is close to one. Measuring the qubits yields marked item
with high probability.
To analyze the behavior of the algorithm, let us assume for simplicity that there is exactly one marked item, . Initially, all basis states have amplitude
. After applying the oracle and the diffusion operator, the amplitude of the marked state increases, while the amplitudes of unmarked states decrease.
Each Grover iteration acts as a rotation in the two-dimensional subspace spanned by the unmarked-state superposition and the marked state
. The rotation angle is
. After
iterations, the state becomes
.
Thus, repeated applications of rotate the initial state toward the marked state. The optimal number of iterations is
,
which maximizes the probability of obtaining upon measurement. Applying
more times causes an overshoot and reduces the success probability.



