Search⌘ K

The Two‐qubit Grover Searching |10>

Understand how the two-qubit Grover searching algorithm uses Hadamard gates, oracles, and diffusion operators to amplify quantum states. Learn how different oracles mark specific states and how phase shifts guide the quantum circuit to achieve search tasks with qubit phase manipulation.

We'll cover the following...
Javascript (babel-node)
qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
qc.barrier()
qc.x(0)
qc.cz(0, 1)
qc.x(0)
qc.barrier()
qc.h(0)
qc.h(1)
qc.x(0)
qc.x(1)
qc.cz(0,1)
qc.x(0)
qc.x(1)
qc.barrier()
qc.h(0)
qc.h(1)
# execute the qc
results = execute(qc,Aer.get_backend('statevector_simulator')).result()
plot_histogram(results.get_counts())

The following figure depicts the complete circuit.

This circuit contains quite a few phase shifts until we apply the Hadamard-gates at the end, and the qubits result in the desired state that the oracle marked.

Most of the gates inside this circuit serve a technical purpose. For instance, the CZCZ-gate allows us to mark one single state in a multi-qubit system.

If we split the overall circuit into pieces and look at these pieces conceptually, we’ll find a familiar structure. We see Hadamard gates at the start and the end. The center parts, consisting of the oracle and the diffuser, represent a ZZ-gate that we apply on the first qubit and an II-gate to apply on the second qubit.

The overall pattern of this circuit resembles an HIHHIH-sequence we apply on the first qubit and an HZHHZH-sequence we apply on the second qubit. The II-gate does not change a qubit, and the Hadamard gate reverts itself. Therefore, the first qubit ends up in the same state it started with. That is 0|0\rangle. The HZHHZH-gate is identical to a NOT ...