Past-paper question · 2015 May-June · Paper 42 · Q5(b)(ii)

Question 5(b)(ii) 2015 · May-June · Paper 42 · 5 marks

Original past-paper question for 5(B)(II)
Original past-paper question for 5(B)(II)
Original past-paper question for 5(B)(II)
Original past-paper question for 5(B)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 5(B)(II)

Official answer for Question 5

Part (b)

(ii)

(ii)

NumberOfItems 10

✓
REPEAT
✓
TRUE
✓
NoMoreSwaps
✓
FOR Pointer 1 TO NumberOfItems – 1
✓
IF NameList[Pointer] > NameList[Pointer + 1]
✓
THEN
✓
NoMoreSwaps FALSE
✓
Temp NameList[Pointer]
✓
NameList[Pointer] NameList[Pointer + 1]
✓
NameList[Pointer + 1] Temp
✓
ENDIF
✓
ENDFOR
✓
NumberOfItems NumberOfItems - 1
✓
UNTIL NoMoreSwaps = TRUE
✓
Mark as follows:
  • change outer loop to a REPEAT/WHILE loop
✓
(1 mark)
  • FOR loop has variable used for final value
✓
(1 mark)
  • Initialise Boolean variable to TRUE
✓
(1 mark)
  • set Boolean variable to FALSE in correct place
✓
(1 mark)
  • number of items to consider on each pass decrements
✓
(1 mark)
  • Correct stopping condition for REPEAT loop
✓
(1 mark)
✓
[max 5]

Mark scheme 9608_s15_ms_42.pdf →

Show text version of question

Question 5

Part (b)

(ii)

Question 5

Data is stored in the array NameList[1:10]. This data is to be sorted.

An alternative sort algorithm is a bubble sort:

FOR ThisPointer ← 1 TO 9 FOR Pointer ← 1 TO 9 IF NameList[Pointer] > NameList[Pointer + 1] THEN Temp ← NameList[Pointer] NameList[Pointer] ← NameList[Pointer + 1] NameList[Pointer + 1] ← Temp ENDIF ENDFOR ENDFOR

(ii)

Rewrite the algorithm in part (b), using pseudocode, to reduce the number of

unnecessary comparisons. Use the same variable names where appropriate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[5]

Question 13

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 9608_s15_qp_42.pdf

Keep practising this topic