Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Algorithms

EasyMedium
123456789101112131415161718192021222324252627
Question 9

An automated laboratory inventory system monitors the remaining volumes (in litres) of chemical reagents stored on a smart shelf.

The algorithm used to check when a reagent needs attention is written in pseudocode below.

1 SET chemicals TO ["acetone", "ethanol", "saline", "hexane", "ether", "glycol", "iodine", "carbon"]
2
3 SET levels TO [0.6, 0.25, 0.04, 0.75, 0.35, 0.08, 0.9, 1.1]
4
5 SET i TO 0
6
7 WHILE i < 8 DO
8
9   IF (levels[i] <= 0.05) THEN
10     SEND (chemicals[i] & " low") TO DISPLAY
11
12   ELSE
13     IF (levels[i] >= 0.3) AND (levels[i] <= 0.4) THEN
14       SEND (chemicals[i] & " review") TO DISPLAY
15     END IF
16   END IF
17
18   SET i TO i + 1
19
20 END WHILE

Give the output produced by this algorithm.

[2]

Algorithms Questions

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