AS · Practice questions · State-transition diagrams

Follow the arrows.

Six original Cambridge-style questions on state-transition diagrams, with mark-scheme style solutions.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

State, input, next.

01
Recall
[2 marks]

State the purpose of a state-transition diagram.

  • To document an algorithm / system whose behaviour depends on its state. ✓
  • It shows the states, the inputs (events) that cause transitions between them, and any outputs. ✓
02
Trace
[3 marks]

Using Fig. 1 of the lesson (the car alarm), give the state after each input and any output, for the inputs: lock, door opened, unlock, door opened.

  • lock: Armed (no output); door opened: Sounding, output siren on. ✓
  • unlock: Disarmed, output siren off. ✓
  • door opened: no transition from Disarmed, so it stays Disarmed with no output. ✓
03
Apply
[4 marks]

A lamp has states Off, Dim and Bright. It starts Off. Pressing the button moves Off to Dim, Dim to Bright and Bright to Off. Holding the button for 3 seconds in any state turns it Off. Complete a state-transition table for the lamp.

  • Off, press, Dim; Dim, press, Bright; Bright, press, Off. ✓
  • Off, hold, Off (or no change). ✓
  • Dim, hold, Off. ✓
  • Bright, hold, Off. ✓
04
Explain
[2 marks]

Explain how a start state and a halting state are shown on a state-transition diagram.

  • The start state has an arrow pointing into it from a dot / from no other state. ✓
  • A halting state is drawn as a double circle; no transitions leave it. ✓
05
Write
[4 marks]

A turnstile has states Locked and Unlocked, starting Locked. Input coin in Locked moves to Unlocked; input push in Unlocked moves to Locked. Other inputs cause no change. The current state is stored in the global variable State. Write a pseudocode procedure Turnstile(Event : STRING) that makes the transitions.

  • PROCEDURE Turnstile(Event : STRING) ... ENDPROCEDURE. ✓
  • CASE OF State (or IF on State) with a branch for each of Locked and Unlocked. ✓
  • "Locked" : IF Event = "coin" THEN State ← "Unlocked" ENDIF. ✓
  • "Unlocked" : IF Event = "push" THEN State ← "Locked" ENDIF, ENDCASE. ✓
06
Analysis
[2 marks]

In Fig. 2 of the lesson, a user wants the keypad to unlock again 10 minutes after it reaches Locked. Describe the change to the diagram.

  • Locked is no longer a halting state: draw it as a single circle. ✓
  • Add an arrow from Locked to 0 fails labelled with the input / event "10 minutes passed". ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.