Introduction to Quantum Computing


In this lesson, you will learn how to use a controlled NOT gate (or C-NOT).

1)      The CNOT gate

Gate icon

Gate name

What it does

Bloch sphere representation

Controlled-NOT gate

Generates entanglement between two qubits





The CNOT gate flips the second qubit (the target qubit) if, and only if, the first qubit (the control qubit) is |1. Einstein referred to entanglement as "spooky action at a distance" because it works even when the qubits are quite far apart. A common application of the CNOT gate is to maximally entangle two qubits into the | Φ + {\displaystyle |\Phi ^{+}\rangle } Bell state; this forms part of the setup of the superdense coding, quantum teleportation, and entangled quantum cryptography algorithms.


2)      Check it works

First of all, check that it works. Implement these two programs in the Composer:

Q Experience






|00> or |11>


|01> or |10>

The control qubit q(0) is |0>, so the other q(1) qubit can be |0> or |1>.


If q(0) is |1> (forced by the X-gate), then q(1) becomes |1> as well.

Did you get the same kind of results?


3) Grover’s algorithm – or ‘Find the Queen’

Grover’s algorithm is a way to select items from a database extremely quickly. It uses superposition (Hadamard gates) and entanglement (CNOT gates). When you copy this program into the Composer, you will be showing how much faster a quantum computer can be compared to a conventional digital computer.

You can view the explanatory video at

Then implement the Grover’s algorithm as shown in Composer below:

Displays results
Grover’s algorithm – finds the queen card
Oracle function: hides the queen card in the fourth slot 
Superimpose two qubits



When we run this program on the simulator, we get this result:

This shows it is certain (probability = 1) that the queen is in the fourth slot (counting from the right). What is significant about this program? Well, if you had four cards laid out in front of you, how quickly could you pick the one with the queen? You have a 0.25 (one in four) probability of picking it first time, 0.33 (one in three) chance of picking it at the second attempt, and so on. In general, it will take you 2.5 selections to find the queen.

However, Grover’s algorithm picks it at the FIRST attempt! So it is a much faster algorithm than any conventional computer can use!



Explore a 360 Video of the IBM Research Quantum Lab – click on picture to view

Check quiz: Entanglement