An agricultural drone performs an automated multispectral scan over a 5x5 grid of a vineyard to detect diseased crops. The algorithm processes the grid to identify the coordinates of a grid cell containing "Blight".
blight_row = -1
blight_col = -1
for y = 0 to 4
for x = 0 to 4
if checkCropHealth(y, x) == "Blight" then
blight_row = y
blight_col = x
endif
next x
next y
| Column 0 | Column 1 | Column 2 | Column 3 | Column 4 | |
|---|---|---|---|---|---|
| Row 0 | Healthy | Healthy | Healthy | Healthy | Healthy |
| Row 1 | Healthy | Healthy | Healthy | Healthy | Healthy |
| Row 2 | Healthy | Healthy | Healthy | Blight | Healthy |
| Row 3 | Healthy | Healthy | Healthy | Healthy | Healthy |
| Row 4 | Healthy | Healthy | Healthy | Healthy | Healthy |
Explain the purpose of the inner iteration structure (the loop using the variable x) in the algorithm in Figure 1.
208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.