Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Interpreting a sliding-puzzle program

Q12.5 1 mark

getTile(row, column) returns the tile value on the 3 x 3 board in position (row, column). The blank space is represented by the value 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;
}
}
}
Figure 17
row \ column012
0476
1381
20 (blank)52

State the purpose of 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 States that the program locates or stores the coordinates of the blank (0) position.

Full-mark answer

It finds and stores the row and column coordinates of the blank space.

Why this answer loses marks

It checks whether the board contains a blank space.

The program does more than detect the blank: it records the position needed by later board operations.