Past-paper question · 2015 May-June · Paper 22 · Q3(f)

Question 3(f) 2015 · May-June · Paper 22 · 5 marks

Question 3

Part (f)

Question 3

A board game is designed for two players, O and X.

At the beginning, all cells of a 3 x 3 grid are empty.

The players take turns in placing their marker in an empty cell of the grid; player O always starts.

The game ends when one player completes a row, column or diagonal or the grid is full.

Here is one example after three turns:

O

O X

Ali wants to write a program to play the game.

Part (f)

The subroutine DisplayGrid is to output the state of play at any time.

For example, after three turns the display should look like:

: : O : O X : : :

where the character ‘:’ shows an empty cell.

Question 3(f) continues on page 12.

Question 12

Write program code for the subroutine algorithm represented by the flowchart:

352&('85( 'LVSOD\*ULG

(PSW\&HOO ®¯

)255RZ

Question 72

/LQH ®¯

)25&ROXPQ

Question 72

*ULG>5RZ&ROXPQ@ 1R (PSW\&HOO " The operator concatenates <HV two strings.

/LQH/LQH ®¯ /LQH/LQH ® ¯ ®¯

*ULG>5RZ&ROXPQ@

1R &ROXPQ " <HV

287387 /LQH

1R 5RZ "

<HV

(1'352&('85(

Question 13

Programming language ............................................................................................................

Code .........................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..............................................................................................................................................

[5]

Question 14

Reveal official mark-scheme answer Official mark-scheme answer for 3(F)

Official answer for Question 3

Part (f)

Part (f)

Example Pascal:

✓
PROCEDURE DisplayGrid;
✓
BEGIN
✓
EmptyCell:= '' // value for empty cell see 3(a)(ii)
✓
FOR Row := 1 TO 3 DO
✓
BEGIN
✓
Line := '';
✓
// build up a row for output
✓
FOR Column := 1 TO 3 DO
✓
IF Grid[Row, Column] = EmptyCell
✓
THEN
✓
Line := Line + ' : '
✓
ELSE
✓
Line := Line + ' ' + Grid[Row, Column] + ' ';
✓
WriteLn(Line);
✓
END;
✓
END;
✓
Mark as follows:
  • Procedure header & ending
  • Assign empty cell value to EmptyCell
  • Correctly nested loops
  • Correct Boolean expression in IF statement
  • Correct string concatenation × 2
  • Initialise line and output line
✓
[max 5]

Mark scheme 9691_s15_ms_22.pdf →

Topic relevance

Why this question appears here

71% assigned-topic match · Algorithm design and problem-solving › Algorithms

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9691_s15_qp_22.pdf

Keep practising this topic