Past-paper question · 2015 May-June · Paper 22 · Q4(c)(v)

Question 4(c)(v) 2015 · May-June · Paper 22 · 5 marks

Original past-paper question for 4(C)(V)
Original past-paper question for 4(C)(V)
Original past-paper question for 4(C)(V)
Original past-paper question for 4(C)(V)
Original past-paper question for 4(C)(V)
Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9691_s15_ms_22.pdf →

Show text version of question

Question 4

Part (c)

(v)

Part (c)

Ali uses the top-down design approach for his overall program solution.

His design is as follows: 01 GameEnd ← FALSE 02 CurrentPlayer ← 'O' 03 CALL DisplayGrid() 04 05 REPEAT 06 CALL PlayerTakesTurn(CurrentPlayer) 07 CALL DisplayGrid() 08 IF HasPlayerWon() = TRUE 09 THEN

Question 10

GameEnd ← TRUE

Question 11

OUTPUT "Player", CurrentPlayer, "has won"

Question 12

ELSE

Question 13

IF GridFull() = TRUE

Question 14

THEN

Question 15

GameEnd ← TRUE

Question 16

OUTPUT "Draw"

Question 17

ELSE

Question 18

CALL SwapPlayer(CurrentPlayer)

Question 19

ENDIF

Question 20

ENDIF

Question 21

UNTIL GameEnd = TRUE

(v)

Complete the identifier table below. Variable or Procedure Identifier Data type Description or Function or Array FALSE if game in progress GameEnd BOOLEAN Variable TRUE if there is a winner or the grid is full Grid ARRAY To store the current state of the game The marker value ('O' or 'X') of the current CurrentPlayer player Current player chooses cell PlayerTakesTurn Program checks if it is valid and stores marker DisplayGrid Outputs the contents of the grid Checks if the current player has completed a HasPlayerWon row, column or diagonal GridFull Checks if the grid is full SwapPlayer PROCEDURE Swaps the value of CurrentPlayer

[5]
Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

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