The Two‐qubit Grover Searching |10>
Get familiarized with the concept of the two‐qubit Grover searching |10>.
We'll cover the following...
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 qcresults = 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 -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 -gate that we apply on the first qubit and an -gate to apply on the second qubit.
The overall pattern of this circuit resembles an -sequence we apply on the first qubit and an -sequence we apply on the second qubit. The -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 ...