Current Article  

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 {λ01,...,λ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 ≠ ω

The steps ofGrover algorithm are:
  1. Initializesystem tostate
    |s⟩ = N-1/2 Σx |x⟩
  2. Performfollowing "Grover iteration" r(N) times.
    r(N)described below;N>>1, r ≈ πN1/2/4.
      1. Applyoperator Uω
      2. Applyoperator Us = 2 |s⟩ ⟨s| - I
  3. 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⟩

Considerplane spanned by |s⟩|ω⟩. Let |ω×⟩ beketthis plane perpendicular|ω⟩. Since |ω⟩one ofbasis vectors,overlap is

⟨ω|s⟩ = N-1/2

In geometric terms, therean angle (π/2 - θ) between |ω⟩|s⟩, where θgiven by:

cos (π/2 - θ) = N-1/2
sin θ = N-1/2

The operator Uω isreflection athyperplane orthogonal|ω⟩;vectors inplane spanned by |s⟩|ω⟩,acts asreflection atline through |ω×⟩. The operator Us isreflection atline through |s>. Therefore,state vector remains inplane spanned by |s⟩|ω⟩ after each applicationUsafter each applicationUω,itstraighforwardcheck thatoperator UsUωeach Grover iteration step rotatesstate vector by an angle2θ toward |ω⟩.

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

However, r must be an integer, so generally we can only set rbeinteger closest(π/θ - 2)/4. The angle between |ω⟩ andfinal state vectorO(θ), soprobabilityobtainingwrong answerO(1 - cos2θ) = O(sin2θ).

For N>>1, θ ≈ N-1/2, so

r ≈ π N1/2 / 4

Furthermore,probabilityobtainingwrong answer becomes O(1/N), which goeszerolarge N.


References:


Copyright 2004. All rights reserved.