IBDP Computer Science B2.3 Programming constructs SL Paper 1 - New Syllabus
Question
nor Boolean operator.

F = 5 S = 30 T = true F >= 25 AND S >= 10 AND S <= 130 AND T = true
Most-appropriate topic code
▶️ Answer/Explanation
(a)
For the correct answer (description OR truth table):
Outputs the value of one if and only if all inputs have a value of zero.

NOR is essentially a NOT applied to an OR gate. It only outputs 1 when every input is 0. The moment any input is 1, the output is 0.
(b)
For the correct answer:
The output Z should represent \(Z = A’ \cdot B + C’\), meaning:
- Correct NOT gate with input A;
- Correct NOT gate with input C;
- Correct AND gate with one input from NOT(A) and one input from B;
- Correct OR gate with inputs from the AND gate output and NOT(C), producing output Z.

Reading the scenario, “travelling forward AND less than 20m” translates to \(B=1\) AND \(A=0\), giving \(B \cdot \overline{A}\). “Speed more than 130 km/h” means \(C=0\), giving \(\overline{C}\). The two conditions are joined by OR, giving \(Z = \overline{A} \cdot B + \overline{C}\).
(c)
For the correct answer (rules for 0 and 1 can be reversed):

Input D follows the same convention as the existing inputs in Figure 1: binary 0 represents the dangerous/trigger condition (obstruction is close), and binary 1 represents the safe condition (no obstruction within 3 m).
(d)
For the correct answer:
5 >= 25 AND 30 >= 10 AND 30 <= 130 AND true false AND true AND true AND true Output = false
Substituting the given values, \(F=5\) fails the first condition \(F \geq 25\). Since AND requires all parts to be true, the entire expression is false.
(e)
For the correct answer:
Use of a flag (or otherwise) to maintain a continuous loop; appropriate loop structure (while/repeat..until); inputs for distance and speed inside the loop; correct conditions to implement alarm notification; correct output of alarm; correct condition to cause the loop to stop. Do NOT accept break to terminate the loop.
FLAG = true
loop while FLAG
input D
input S
if D < 20 OR S > 130 then
output "ALARM!!"
end if
if S = 0 then
FLAG = false
end if
end loopThe algorithm uses a boolean flag to keep the loop running while the car is moving. Inside the loop, it reads the distance and speed inputs, checks whether either threshold is breached, and outputs an alarm if so. The loop only exits when speed equals zero, meaning the car has stopped.
