Classically, searching an unsorted database requires a linear search, which is O(N). Grover's algorithm provides "only" quadratic speedup, unlike other quantum algorithms which are thought to provide exponential speedup over their classical counterparts. However, it is the fastest possible quantum algorithm for searching an unsorted database, and even quadratic speedup is considerable when N is large.
Like all quantum computer algorithms, Grover's algorithm is probabilistic in the sense that it gives the correct answer with high probability. The probability of failure can be decreased by repeating the algorithm.
Although Grover's algorithm is often described as searching a database, it would be more accurate to describe it as inverting a function. If a function y=f(x) can be computed by an algorithm for a quantum computer, then Grover's algorithm can calculate x, given y. Grover's algorithm wouldn't typically be used to search for names in a phone book, but it could be used to search for a key that decrypts an encrypted message. If the function for computing f(x) is given as a black box, then Grover's algorithm is the fastest possible algorithm for inverting it.
Grover's algorithm can be used for mean and median estimation, and solving the collision problem[?]. It can be used to solve NPcomplete problems by performing exhaustive searches over all possible solutions. This will result in considerable speedups over classical methods, but won't achieve polynomial runtime for NPcomplete problems.
Below, we present the basic form of Grover's algorithm, which searches for a single matching entry. The algorithm can be further optimized if there is more than one matching entry and the number of matches is known beforehand.
Consider an unsorted database with N entries. The algorithm requires an Ndimensional state space H, which can be supplied by log_{2}N qubits.
Number the database entries 0, 1, ... N1. Choose an observable Ω acting on H with N distinct eigenvalues. By the spectral theorem, we can construct an orthonormal basis of eigenkets {0⟩,1⟩,...N1⟩} (see braket notation). The eigenvalues {λ_{0},λ_{1},...,λ_{N1}} label distinct database entries. We wish to find the label ω⟩ for the database entry matching our search criterion.
We are provided with a unitary operator U_{ω} which compares database entries with our search criterion. The algorithm does not specify how this subroutine works, but it must be a quantum subroutine that works with superpositions of states, and it must have the following effects on the label kets:
The steps of the Grover algorithm are:
Our initial state is
Consider the plane spanned by s⟩ and ω⟩. Let ω^{×}⟩ be a ket in this plane perpendicular to ω⟩. Since ω⟩ is one of the basis vectors, the overlap is
In geometric terms, there is an angle (π/2  θ) between ω⟩ and s⟩, where θ is given by:
The operator U_{ω} is a reflection at the hyperplane orthogonal to ω⟩; for vectors in the plane spanned by s⟩ and ω⟩, it acts as a reflection at the line through ω^{×}⟩. The operator U_{s} is a reflection at the line through s>. Therefore, the state vector remains in the plane spanned by s⟩ and ω⟩ after each application of U_{s} and after each application of U_{ω}, and it is straighforward to check that the operator U_{s}U_{ω} of each Grover iteration step rotates the state vector by an angle of 2θ toward ω⟩.
We need to stop when the state vector passes close to ω⟩; after this, subsequent iterations rotate the state vector away from ω⟩, reducing the probability of obtaining the correct answer. The number of times to iterate is given by r. In order to align the state vector exactly with ω⟩, we need:
However, r must be an integer, so generally we can only set r to be the integer closest to (π/θ  2)/4. The angle between ω⟩ and the final state vector is O(θ), so the probability of obtaining the wrong answer is O(1  cos^{2}θ) = O(sin^{2}θ).
For N>>1, θ ≈ N^{1/2}, so
Furthermore, the probability of obtaining the wrong answer becomes O(1/N), which goes to zero for large N.
References:
Search Encyclopedia

Featured Article
