Past-paper question · 2015 May-June · Paper 23 · Q3(a)(v)

Question 3(a)(v) 2015 · May-June · Paper 23 · 5 marks

Original past-paper question for 3(A)(V)
Original past-paper question for 3(A)(V)
Original past-paper question for 3(A)(V)
Reveal official mark-scheme answer Official mark-scheme answer for 3(A)(V)

Official answer for Question 3

Part (a)

(v)

(v)

✓
n 4
✓
REPEAT
✓
NoMoreSwaps TRUE
✓
FOR j 1 TO n
✓
IF Numbers[j] > Numbers[j + 1]
✓
THEN
✓
w Numbers[j]
✓
Numbers[j] Numbers[j + 1]
✓
Numbers[j + 1] w
✓
NoMoreSwaps FALSE
✓
ENDIF
✓
ENDFOR
✓
n n - 1
✓
UNTIL NoMoreSwaps = TRUE
✓
Marks as follows:
  • Upper bound of FOR loop set to n
  • Decrement n after FOR loop
  • Set Boolean variable to TRUE in outer loop, before inner loop
  • Set Boolean variable to FALSE within THEN part
  • UNTIL expression correct
[5]

Mark scheme 9691_s15_ms_23.pdf →

Show text version of question

Question 3

Part (a)

(v)

Meena has written the algorithm below and wants to check that it works correctly.

FOR i ← 1 TO 4 FOR j ← 1 TO 4 IF Numbers[j] > Numbers[j + 1] THEN w ← Numbers[j] Numbers[j] ← Numbers[j + 1] Numbers[j + 1] ← w ENDIF ENDFOR ENDFOR

(v)

Meena has started to write an improved version of the algorithm.

Complete the pseudocode.

n ← 4

REPEAT

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

FOR j ← 1 TO ..........................................................................................................

IF Numbers[j] > Numbers[j + 1]

THEN

w ← Numbers[j]

Numbers[j] ← Numbers[j + 1]

Numbers[j + 1] ← w

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

ENDIF

ENDFOR

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

UNTIL ..........................................................................................................................[5]

Question 14

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_23.pdf

Keep practising this topic