EcoTemp uses automated sensors to monitor greenhouse temperatures.
Programmers are developing an algorithm to detect if any temperature readings exceed 35°C to trigger a ventilation alert. They are testing the algorithm with a small dataset to verify its efficiency before deploying it to handle larger, continuous streams of sensor data.
Here is the pseudo-code for the containment alert algorithm:
1 SET maximum TO LENGTH(temperatures)
2 SET i TO 0
3 SET highTempFound TO FALSE
4
5 WHILE (i < maximum) DO
6 IF (temperatures[i] > 35) THEN
7 SET highTempFound TO TRUE
8 END IF
9 SET i TO i + 1
10 END WHILE
11
12 IF (highTempFound == TRUE) THEN
13 SEND "Warning: High temperature detected!" TO DISPLAY
14 END IF
Here is the test dataset stored in the array temperatures:
21, 23, 39, 22, 20, 24
Describe one inefficiency when executing the algorithm with this dataset.
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.