A council uses a computational model to predict when a road junction should show a red signal to prevent congestion. At the start of the model there are 12 ...

Assessment: Computer Science 4CP0 | Paper 1 Mock 01 | Written Paper 1 Subject: Computer Science - 4CP0

Question 1 Report

A council uses a computational model to predict when a road junction should show a red signal to prevent congestion. At the start of the model there are 12 cars waiting. During each minute, sensors provide the number of cars that entered the queue and the number that left it. The model updates the value of cars. If more than 20 cars are waiting, it sets signal to RED; otherwise it sets signal to GREEN.

cars ← 12
FOR minute ← 1 TO 4
    INPUT entered, left
    cars ← cars + entered - left
    IF cars > 20 THEN
        signal ← "RED"
    ELSE
        signal ← "GREEN"
    ENDIF
    OUTPUT cars, signal
NEXT minute

The sensor data are shown below. A separate sensor records 00011000 as an eight-bit binary car count. The model is an approximation: it does not include factors such as weather, pedestrians or drivers ignoring signals.

Minuteenteredleftcars after updatesignal
183??
292??
374??
436??

(a) State the two values input by the sensors on each iteration. [2]
(b) Identify the line or structure that repeats the model for each minute. [1]
(c) Complete the trace table. [4]
(d) Complete the data types: cars is an __________; signal is a __________. [2]
(e) Convert 00011000 from binary to denary. [1]
(f) Give one factor, other than those stated, that could make this model less accurate. [1]
(g) Explain why the council should validate sensor input values before using them in the model. [2]
(h) State one value output by the model during each iteration. [1]

Answer Details

(a) The sensors input entered and left on each iteration [2].

(b) The FOR...NEXT loop repeats the model for each minute [1].

(c)

MinuteCars after updateSignal
1\(12+8-3=\textbf{17}\)GREEN
2\(17+9-2=\textbf{24}\)RED
3\(24+7-4=\textbf{27}\)RED
4\(27+3-6=\textbf{24}\)RED

A red signal is selected only when the updated count is greater than 20 [4].

(d) cars is an integer; signal is a string [2].

(e) \(00011000_2=16+8=\textbf{24}\) [1].

(f) A faulty sensor could make the model less accurate [1].

(g) Validation can reject impossible or erroneous readings, such as a negative number of cars. This prevents invalid input producing an unrealistic queue total and an incorrect signal decision [2].

(h) One output on each iteration is cars [1]. signal is also valid.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning