Worked example · Computer Science · Year 10
DCF: Data and computational thinking → Problem-solving and modelling
A complete, correct set of answers. Every output column below has been checked against the gate definitions row by row, so you can mark the class straight off this sheet. Show it after pupils have attempted all five scenarios.
D = driver's door is open. P = passenger door is open. L = interior light is on.
L = D OR P
| D | P | L |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Only the first row leaves the light off, which is right: the light stays off exactly when every door is shut.
Inputs defined in words before the expression is written, and all four rows present in binary counting order — first and second success criteria.
M = C AND T
| C (door closed) | T (timer running) | M (heating) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Why AND and not OR: look at row 2. The door is open and the timer is running. With AND the output is 0, so nothing happens. With OR it would be 1 — the microwave would fire microwaves out of an open door at whoever is standing there. This is a safety interlock, so the only acceptable output for row 2 is 0, and AND is the only one of the two gates that gives it.
The answer names the row that decides the question rather than describing AND in general — third success criterion.
A = S AND (NOT T)
| S (smoke) | T (silence held) | NOT T | A (sounder) |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
The sounder goes off in exactly one case — smoke detected and nobody holding the silence button, which is row 3. Row 4 is the test: there is smoke, but staff are holding the button, so the building is not evacuated.
Uses an intermediate NOT T column so the working can be followed, and the output matches the device's real behaviour in all four cases.
L = A XOR B
| A (bottom switch up) | B (top switch up) | L (light on) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XOR is the gate where changing either input always changes the output. Start on row 1 with the light off, flick the bottom switch and you move to row 3 — the light comes on. Flick the top one instead and you move to row 2 — also on. From row 4, flicking either switch turns it off. That is exactly what a two-way landing light does, and it is why neither switch has a fixed "on" position.
Explains the table as movement between rows, which is what makes XOR the right choice rather than a coincidence.
F = (H AND W) OR O
| H | W | O | H AND W | F |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Three inputs give 2³ = 8 rows, written in binary counting order 000 to 111 so none can be missed. The H AND W column is 1 only in the last two rows. F is 1 in five rows: every row where O = 1 (the override always wins) plus row 7, where it is hot, the window is closed and nobody has pressed anything. Row 5 is the interesting one — hot but the window is open, so the fan stays off, which is exactly the rule the gardener asked for.
Eight rows in systematic order, an intermediate column, and a circuit that matches the expression gate for gate — second and fourth success criteria.
The electrician's wiring: A = S OR (NOT T)
| S | T | NOT T | A = S OR (NOT T) |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
Row 1 is the proof. There is no smoke and nobody is touching the silence button — a normal quiet afternoon — and the sounder is on. The alarm would ring continuously all day, and would only stop when a member of staff stood there holding the silence button down, which is the opposite of what the button is for. Compare the two output columns: the correct circuit gives 0, 0, 1, 0, and this one gives 1, 0, 1, 1 — it is wrong in three of the four possible situations.
Names the exact row that breaks, then compares the two output columns to quantify how wrong the design is — fifth success criterion.
A NAND gate with both inputs tied together acts as a NOT gate, because NAND(x, x) = NOT(x AND x) = NOT x. So feeding C NAND T into a second NAND with itself gives NOT(C NAND T), which is C AND T.
M = (C NAND T) NAND (C NAND T)
| C | T | C NAND T | NAND of that with itself | C AND T |
|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 |
The last two columns are identical in all four rows, so the two-NAND circuit and the AND gate are interchangeable. This is why a chip manufacturer can build a whole processor out of one kind of gate.
Equivalence proved by putting both output columns side by side, which is the standard method.