1
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer

qreg = QuantumRegister(2)
creg = ClassicalRegister(2)
circuit = QuantumCircuit(qreg,creg)

circuit.x(qreg[0]) #10
circuit.x(qreg[1]) #11
circuit.cx(qreg[0],qreg[1]) #?

circuit.measure(qreg,creg)
job = execute(circuit,Aer.get_backend('qasm_simulator'),shots=1024)
counts = job.result().get_counts(circuit)
print(counts)

# CNOT gate: performs a NOT on the target whenever the control is in state 1.

OUTPUT: {'01': 1024} MY EXPECTATION: {'10': 1024}

1 Answers1

1

This is because Qiskit uses little-endian ordering for both classical bits and qubits.

See this answer for more details.

Egretta.Thula
  • 9,972
  • 1
  • 11
  • 30
  • Please elaborate on your answer. I guess you are saying that there is no logical difference between the OUTPUT and MY EXPECTED OUTPUT ? – Anees Ur Rehman Aug 05 '23 at 14:35
  • It is just a convention. When the first bit equals $1$ and the second bit equals $0$, and we are using little-endian ordering, we write the bitstring as $01$. That is, we write the first bit on the right-most side. On the other hand, many quantum computing books use big-endian ordering. So, they write the same bitstring as $10$ – Egretta.Thula Aug 05 '23 at 14:47
  • I got it, thank you. – Anees Ur Rehman Aug 05 '23 at 14:52