Skip to content
Tech Interview Prep
Technical interview guide

Quantum Gates & the Circuit Model

How quantum programs are expressed as circuits of unitary gates acting on qubits: the single- and multi-qubit gates every quantum algorithm is built from.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: IBM Quantum and Qiskit current circuit/transpiler documentation; OpenQASM 3; QIR specification reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Quantum Gates & the Circuit Model

In one line

A circuit is an ordered list of unitary gates on qubits, ending in measurements. Reach for it whenever you must state what a small program outputs, and name the conventions (qubit order, matrix order, global phase, control and target) that make that output correct.

Key definitions

  • Unitary: $U^\dagger U = I$. It preserves inner products and total probability, so every ideal gate is reversible.
  • Global phase: a factor $e^{i\alpha}$ on the whole state. It is unobservable alone and becomes observable once the gate is controlled.
  • Clifford group: generated by H, S and CNOT. Clifford circuits are efficiently simulable (Gottesman-Knill).
  • Native gate set: the instructions a backend runs directly. Everything else is decomposed into them.
  • Routing: inserting SWAPs so every two-qubit gate acts on a physically coupled pair.
  • Mid-circuit measurement: non-unitary. It collapses the qubit and can drive classical control.

Formulas and complexity

H=12(111−1),HXH=Z,HZH=X,HYH=−YH=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix},\qquad HXH=Z,\qquad HZH=X,\qquad HYH=-Y U=eiα Rz(β) Ry(γ) Rz(δ)(ZYZ: any single-qubit unitary)U = e^{i\alpha}\,R_z(\beta)\,R_y(\gamma)\,R_z(\delta)\qquad\text{(ZYZ: any single-qubit unitary)} CZ=(I⊗H) CNOT (I⊗H)\mathrm{CZ}=(I\otimes H)\,\mathrm{CNOT}\,(I\otimes H) full unitary check: 4n entries, so 416≈4.3×109\text{full unitary check: } 4^n \text{ entries, so } 4^{16}\approx 4.3\times10^{9}

SWAP costs three CNOTs. A standard Toffoli uses six CNOTs plus single-qubit gates. On a line of $n$ qubits, a CNOT between qubits at distance $d$ needs $d-1$ SWAPs.

How it works

Gates are applied in diagram order (left to right in time), but matrices multiply right to left, so $U = G_n \cdots G_2 G_1$. Each gate acts on the state produced by the one before it.

  • Bell state: H on q0 gives (|00⟩+|10⟩)/√2. CNOT(q0,q1) sends |10⟩ to |11⟩, giving (|00⟩+|11⟩)/√2.
  • Qiskit puts q0 at the least significant bit, so the amplitude of |q1 q0⟩ = |10⟩ sits at index 2. State the convention before reading any index.
  • A Z-basis measurement is blind to Z, S and T. Those gates only show up after a basis change.
Prepare 00 H on q0 CNOT control q0 target q1 Measure both in Z Counts: 00 and 11 about 50 percent each

When to use and when not to

SituationAnswerWhy
Exact output of a few-qubit circuitCompute amplitudes by hand or statevectorExact and cheap at small n
Clifford-only circuit, many qubitsStabilizer simulatorPolynomial in qubit count
Circuit with T gates, large nStatevector, cost grows as 2^nT is non-Clifford, no shortcut
Equality of two small rewritesFull unitary comparison, including phaseCatches phase errors in controlled use
Equality of two large rewritesInverse composition on random inputs, or samplingNever materializes the unitary

Traps interviewers probe

  1. Treating X as a phase multiply. X must swap the two amplitudes. Multiplying both by one phase leaves |0⟩ unchanged. Fix: assert the amplitude vector, not just measurement counts.
  2. Calling Y a phased X. Y|0⟩ = i|1⟩ and Y|1⟩ = -i|0⟩ carry relative signs that X does not. Fix: write the action on both basis states.
  3. Dropping the global phase on a block that will be controlled. Controlled-(-U) equals controlled-U followed by Z on the control. Fix: record the phase and test the block in controlled form.
  4. Reading X-basis results without the final H. Z before measurement does not change Z counts. For |+⟩, then Z, then H, then Z-measure, all 1000 shots read 1. Fix: apply H before a Z-basis readout to measure in the X basis.
  5. Quoting abstract gate counts. A SWAP costs three CNOTs, and routing on a line adds them quickly. Fix: report the transpiled two-qubit count and layout next to the abstract count.

Interview tips

Open by fixing the conventions: qubit order, control and target, and matrix order. Then trace the state in amplitudes, one gate at a time.

Expect these follow-ups:

  • Why CZ is symmetric and CNOT is not.
  • Why T costs more than CNOT in fault-tolerant compilation (magic-state distillation).
  • How many SWAPs a distance-d CNOT needs on a line.
  • How you would verify a rewrite of a 20-qubit circuit.

30-second outline: pin the conventions. H gives an equal superposition, and CNOT correlates the qubits. Measurement gives 00 and 11 at 50 percent each. On hardware, CNOT is the expensive gate, routing adds three CNOTs per SWAP, and equivalence is checked by comparing unitaries with phase, or by sampling on asymmetric inputs.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.