Academy K

SWAP from CNOTs

Warm-upCodingSWAPCNOTcircuit identities

Related module: Gates and circuits

Problem statement

The SWAP gate exchanges two qubits: ∣a,b⟩→∣b,a⟩|a,b\rangle \to |b,a\rangle.

  1. Show that SWAP = CNOT(1,2) · CNOT(2,1) · CNOT(1,2) where CNOT(i,j) has i as control, j as target.
  2. Implement this in Qiskit-style pseudocode.

Practise this problem

Verify you understand it—not just that you read the answer.

Learn the foundations

The Quantum Computing track covers this topic and more in depth.