Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Second iteration through puzzle positions

Q12.4 1 mark

getTile(row, column) returns the tile value at a position on the 3 x 3 board; the blank space is represented by 0.

Figure 16
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 second 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. 1 Explains that the inner/second loop iterates through the board columns.

Full-mark answer

It iterates through the columns of each row.

Why this answer loses marks

It repeats the search inside the first loop.

This describes nesting but does not name the dimension traversed by the second loop.