Here is a pseudo-code algorithm designed to schedule the nutrient dosage scaling for a hydroponic cultivation facility over a 6-stage crop growth cycle.
1 # Hydroponic nutrient dosing scheduler
2 SET stageName TO ["G1", "G2", "G3", "G4", "G5", "G6"]
3 SET concentrationPercent TO [105, 120, 135, 150, 165, 180]
4 SET inputValid TO False
5
6 # Validate baseline concentration in ppm
7 WHILE (inputValid = False) DO
8 SEND "Enter the baseline concentration in ppm (min 400): " TO DISPLAY
9 RECEIVE baseConcentration FROM (INTEGER) KEYBOARD
10
11 IF (baseConcentration >= 400) THEN
12 SET inputValid TO True
13 SEND "Baseline concentration accepted: " & baseConcentration TO DISPLAY
14 ELSE
15 SEND "Concentration too low" TO DISPLAY
16 END IF
17 END WHILE
18
19 # Calculate scheduled concentrations
20 FOR i FROM 0 TO (LENGTH(stageName) - 1)
21 SET scale TO concentrationPercent[i] / 100
22 SET scheduledDose TO baseConcentration * scale
23 SEND "Stage " & stageName[i] & " dose: " & scheduledDose TO DISPLAY
24 END FOR
Complete the trace table to show the execution of lines 20 to 24 of the pseudo-code for the loop iteration where i = 3 when the user enters the value 600 at line 9.
| baseConcentration | i | LENGTH(stageName) | scale | concentrationPercent[i] | scheduledDose |
|---|---|---|---|---|---|
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.