Grover's algorithm
Grover's algorithm isquantum algorithmsearching an unsorted databaseN entriesO(N1/2) timeO(log2N) space. It was invented by Lov Grover1996.Classically, searching an unsorted database requireslinear search, whichO(N). Grover's algorithm provides "only" quadratic speedup, unlike other quantum algorithms whichthoughtprovide exponential speedup over their classical counterparts. However,isfastest possible quantum algorithmsearching an unsorted database,even quadratic speedupconsiderable when Nlarge.
Like all quantum computer algorithms, Grover's algorithmprobabilistic insense thatgivescorrect answerhigh probability. The probabilityfailure can be decreased by repeatingalgorithm.
Although Grover's algorithmoften described as searchingdatabase,would be more accuratedescribeas invertingfunction. Iffunction y=f(x) can be computed by an algorithm forquantum computer, then Grover's algorithm can calculate x, given y. Grover's algorithm wouldn't typically be usedsearchnames inphone book, butcould be usedsearch forkey that decrypts an encrypted message. Iffunctioncomputing f(x)given asblack box, then Grover's algorithm isfastest possible algorithminverting it.
Grover's algorithm can be usedmeanmedian estimation,solvingcollision problem. It can be usedsolve NP-complete problems by performing exhaustive searches over all possible solutions. This will resultconsiderable speedups over classical methods, but won't achieve polynomial runtimeNP-complete problems.
Below, we presentbasic formGrover's algorithm, which searches forsingle matching entry. The algorithm can be further optimized if theremore than one matching entry andnumbermatchesknown beforehand.
Procedure
Consider an unsorted databaseN entries. The algorithm requires an N-dimensional state space H, which can be supplied by log2N qubits.
Numberdatabase entries 0, 1, ... N-1. Choose an observable Ω acting on HN distinct eigenvalues. Byspectral theorem, we can construct an orthonormal basiseigenkets {|0〉,|1〉,...|N-1〉} (see bra-ket notation). The eigenvalues {λ0,λ1,...,λN-1} label distinct database entries. We wishfindlabel |ω〉 fordatabase entry matching our search criterion.
Weprovided withunitary operator Uω which compares database entriesour search criterion. The algorithm does not specify how this subroutine works, butmust bequantum subroutine that workssuperpositionsstates,it must havefollowing effects onlabel kets:
- Uω |ω〉 = - |ω〉
- Uω |x〉 = |x〉 x ≠ ω
- Initializesystem tostate
- |s〉 = N-1/2 Σx |x〉
- Performfollowing "Grover iteration" r(N) times.
r(N)described below;N>>1, r ≈ πN1/2/4.- Applyoperator Uω
- Applyoperator Us = 2 |s〉 〈s| - I
- Performmeasurement Ω. The measurement result will be λωprobability approaching 1N>>1. From λω, ω may be obtained.
Explanation ofAlgorithm
Our initial state is
- |s〉 = N-1/2 Σx |x〉
- 〈ω|s〉 = N-1/2
- cos (π/2 - θ) = N-1/2
- sin θ = N-1/2
We needstop whenstate vector passes close|ω〉; after this, subsequent iterations rotatestate vector away from |ω〉, reducingprobabilityobtainingcorrect answer. The numbertimesiterategiven by r. In orderalignstate vector exactly|ω〉, we need:
- π/2 - θ = 2θr
- r = (π/θ - 2)/4
For N>>1, θ ≈ N-1/2, so
- r ≈ π N1/2 / 4
References:
- Grover L.K.: A fast quantum mechanical algorithmdatabase search, Proceedings, 28th Annual ACM Symposium onTheoryComputing, (May 1996) p. 212
- http://www.bell-labs.com/user/feature/archives/lkgrover/
