AQA · GCSE · Computer Science · Higher
First iteration through puzzle positions
getTile(row, column) returns the tile value at a position on the 3 x 3 board; the blank space is represented by 0.
| int ref1, ref2; |
| for (int i = 0; i < 3; i++) |
| { |
| for (int j = 0; j < 3; j++) |
| { |
| if (getTile(i, j) == 0) |
| { |
| ref1 = i; |
| ref2 = j; |
| } |
| } |
| } |
Explain the purpose of the first iteration structure in the program in Figure 16.
Write your answer first. You can study the marking guidance whenever you need it.
Study the marking See what earns credit and compare it with a full-mark answer.
Marking points
- 1 Explains that the outer/first loop iterates through the board rows.
Full-mark answer
It iterates through the rows of the board.
Why this answer loses marks
It checks the whole board.
This is too broad for the first loop: the answer must identify the board dimension that this loop traverses.