Stage 2 · Lesson 7 of 17

Why instruction order matters

40 minutesNo coding required10-question quiz

1 · Big question

Can the same gates perform different computations when their order changes?

  • Explain why circuit order is part of a computation.
  • Predict H→Z→H on |0⟩.
  • Predict Z→H→H on |0⟩.
  • Use state checkpoints to justify different outcomes.

2 · Before we begin

Ideas to bring with you

  • H can prepare and analyse phase.
  • Z changes relative phase.

3 · New words

Meet the words before we use them

instruction order
The left-to-right sequence in which circuit operations act.
checkpoint
A calculated state or probability view after a circuit step.
analyse
Use a later operation and measurement to reveal a state feature.

4 · Simple explanation

Build one idea at a time

Circuit instructions act in sequence. A later gate receives the state produced by every gate before it.

Starting from |0⟩, H→Z→H produces |1⟩. The first H creates |+⟩, Z changes it to |−⟩, and the last H maps |−⟩ to |1⟩.

Starting from |0⟩, Z→H→H produces |0⟩. Z leaves |0⟩ unchanged and the two H gates cancel in this case.

Watch it happen

Same gates, different order

Calculated teaching model

Rearrange H, Z and H, predict first, then reveal calculated state checkpoints.

Ready. Use Step or Play to begin.
Text description of the animation

Two circuits start at |0⟩. H-Z-H ends at |1⟩; Z-H-H ends at |0⟩. A table names the state after each gate.

  1. Predict both required circuits.
  2. Step through Circuit A and record each state label.
  3. Step through Circuit B, then compare and justify the two required orders.

Evidence to calculate or record: Circuit A is certain 1 and Circuit B certain 0 in the ideal model, supported by their state checkpoints.

Predict

Commit to an idea before the reveal

Circuit A and Circuit B contain the same gate names. Must they have the same ideal measurement result?

Choose a prediction to enable the experiment.

Try it

Compare and justify

Teaching model

Predict both required circuits.

Make and lock a prediction first.

Detailed activity results will appear here.

8 · Observe

What did the result actually show?

Look at the displayed values before reading the explanation. Record a pattern, an exception or something that changed.

The two final probability panels differ even though the multiset of gate names is the same.

9 · Explain the result

Connect the evidence to the idea

Quantum operations combine in order. Swapping H and Z can change the state supplied to later operations, so their order cannot be ignored.

10 · Model and limitation

Useful model, honest boundary

What this model shows

Checkpoints expose the reason for the final result rather than showing only an answer.

What this model does not show

A recipe analogy helps with sequence, but quantum gates transform amplitudes and phase rather than food ingredients. Where this analogy stops: recipes do not model quantum interference.

11 · Common mix-ups

Careful wording prevents big mistakes

The same gate names always mean the same computation.

Order can change the state entering each later gate.

Z has no effect because it leaves |0⟩ unchanged.

Its effect depends on the state at the moment it acts.

Only the final gate matters.

Every earlier gate helps determine the state supplied to the final gate.

12 · Real quantum-computing connection

Where this appears in circuit work

Circuit optimisation and debugging both preserve or test the ordered mathematical operation, not merely the list of gate names.

13 · Show me moreOptional deeper explanation

Show me more

In matrix notation, the rightmost operation acts first on a state vector. This course keeps the learner-facing circuit order left to right and uses checkpoints to avoid notation confusion.

Try this

Explain the deeper idea in your own words, including one limitation.

14 · Quick summary

Keep these ideas

  • Gate order is part of the computation.
  • HZH|0⟩ gives |1⟩.
  • ZHH|0⟩ gives |0⟩.
  • State checkpoints explain the difference.

Ten-question quiz

Check the ideas—not decorative details

Feedback appears after submission. Retry whenever you like; 8/10 or above means “Topic understood”.

1Why is circuit order important?

Concept · Easy

2What is the ideal final state of H→Z→H on |0⟩?

Concept · Medium

3What is the ideal final state of Z→H→H on |0⟩?

Concept · Medium

4What is a state checkpoint?

Vocabulary · Easy

5What does an analysing gate help do?

Vocabulary · Easy

6What should the final HZH histogram approach over many ideal shots?

Prediction · Medium

7A learner moves Z from the middle of H-Z-H to the beginning. Which required circuit results?

Prediction · Medium

8Which claim is disproved by the two required circuits?

Misconception · Easy

9Which evidence best explains why HZH ends at |1⟩?

Evidence · Medium

10A circuit expected to output 1 instead outputs 0 ideally. What should be checked first?

Application · Medium

Sources and accuracy notes3 checked references · reviewed 2026-08-15

These records identify the claim each source supports. External documentation can change; dated platform claims were checked on the shown access date.

  1. CircuitsIBM Quantum Learning · Quantum circuits — Circuits · accessed 2026-08-15

    Supports quiz questions ql-07-q-01, ql-07-q-04, ql-07-q-07, ql-07-q-08, ql-07-q-10 and their related lesson explanations about classical and quantum circuit models; gates and wires; standard-basis measurement.

  2. Quantum informationIBM Quantum Learning · Single systems · accessed 2026-08-15

    Supports quiz questions ql-07-q-02, ql-07-q-03, ql-07-q-06 and their related lesson explanations about state vectors; normalisation; single-system measurement probabilities.

  3. Quantum Computer Science: An IntroductionCambridge University Press · 2007 · Chapters 1–4 · accessed 2026-08-15

    Supports quiz questions ql-07-q-05, ql-07-q-09 and their related lesson explanations about qubits, gates and circuits; entanglement and teleportation; introductory quantum algorithms.

Lesson accuracy notes
  • This model is deliberately limited: A recipe analogy helps with sequence, but quantum gates transform amplitudes and phase rather than food ingredients. Where this analogy stops: recipes do not model quantum interference.
  • Predictions, simulations and physical-hardware evidence are labelled separately.