Skip to main content

12.9 Grover’s search algorithm

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §12.9–12.9.1. Original prose — no Qiskit oracle listing dumps. Continues 12.8b. Labs: 12.9b.

Classical lookup of one marked index among NN unsorted items costs O(N)O(N) queries in the worst case. Grover’s algorithm finds a marked item with O(N)O(\sqrt N) oracle calls on a quantum computer.

Database toy model​

Suppose N=16=24N=16=2^4 entries (j,Vj)(j,V_j) — e.g. j=8j=8 stores V=90V=90. Searching needs 4 qubits. Goal: amplify the computational-basis state ∣i⟩|i\rangle that encodes the desired index.

Uniform start + oracle + diffuser​

Initialize ∣0⟩⊗n|0\rangle^{\otimes n}, apply H⊗nH^{\otimes n} for a uniform superposition, then iterate oracle + diffuser. Pick the oracle phase-mark, the diffuser UψU_\psi, and the ∼πN/4\sim\pi\sqrt N/4 iteration count among lookalikes.

Figure 12.10 — oracle schematic.

For ∣15⟩=∣1111⟩|15\rangle=|1111\rangle, a multi-controlled ZZ sandwiched by Hadamards on the target line implements the mark. Other indices: wrap selected qubits with XX so the all-11 pattern of the CCCZ hits the desired bitstring (e.g. ∣9⟩=∣1001⟩|9\rangle=|1001\rangle).

Geometrically the diffuser sends each amplitude αk\alpha_k to 2αˉ−αk2\bar\alpha-\alpha_k. One Grover operator G=UψOG=U_\psi\mathcal O boosts the marked amplitude before over-rotation.

Figure 12.11 — Grover iterate.

Lab: wire Grover skeleton​

Simulator vs hardware​

Ideal simulators show a sharp peak (e.g. ∣1001⟩|1001\rangle for i=9i=9). Physical backends smear that peak — noise, not a failure of the algorithm’s math.

Figure 12.12 — simulator vs hardware.

Exercise idea: mark j=8j=8 (V=90V=90) and check the measured bitstring decodes to 88.

Takeaway​

PieceRole
H⊗nH^{\otimes n}uniform superposition
Oracle O\mathcal Ophase-flip $
Diffuser UψU_\psiinvert about mean
∼πN/4\sim\pi\sqrt N/4 roundsamplify then measure
Quiz

Grover

1 / 3

The oracle marks the answer by…

Pick an answer to see if you are right.

Next: 12.9b Grover labs.