Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
Question 32

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.

[2]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

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.

Question bank