An algorithm designed to monitor the safety status of a chemical reactor based on its core temperature is shown below.
1 SET reactorTemp TO 112.4
2
3 IF (reactorTemp >= 150.0) THEN
4 SEND "Critical" TO DISPLAY
5 END IF
6 IF (reactorTemp >= 100.0) AND (reactorTemp < 150.0) THEN
7 SEND "High" TO DISPLAY
8 END IF
9 IF (reactorTemp >= 50.0) AND (reactorTemp < 100.0) THEN
10 SEND "Normal" TO DISPLAY
11 END IF
12 IF (reactorTemp < 50.0) THEN
13 SEND "Low" TO DISPLAY
14 END IF
The programmer notes that using consecutive, independent selection statements makes this algorithm highly inefficient.
Explain how the structure and conditions of this algorithm should be modified to resolve these inefficiencies.
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.