Past-paper question · 2016 October-November · Paper 42 · Q4(a)(iii)

Question 4(a)(iii) 2016 · October-November · Paper 42 · 2 marks

Original past-paper question for 4(A)(III)
Original past-paper question for 4(A)(III)
Original past-paper question for 4(A)(III)
Reveal official mark-scheme answer Official mark-scheme answer for 4(A)(III)

Official answer for Question 4

Part (a)

(iii)

(iii)

1 mark for identifying the correct line, 1 mark for writing the corrected line

✓
A - Line 5
✓
B - Line 6
✓
C - Line 5
[1]
✓
for i in range(Max-1):
✓
FOR i := 1 TO (Max-
✓
For i = 0 To
[1]
✓
1) DO
✓
(Max – 1)

Mark scheme 9608_w16_ms_42.pdf →

Show text version of question

Question 4

Part (a)

(iii)

Question 4

Circle the programming language that you have studied:

Visual Basic (console mode) Python Pascal Delphi (console mode)

(iii)

The table shows a module definition for BubbleSort in three programming languages.

Study one of the examples. Indicate your choice by circling A, B or C:

A
B C

A) Python 01 def BubbleSort(SList, Max): 02 NoMoreSwaps = False 03 while NoMoreSwaps == False: 04 NoMoreSwaps = True 05 for i in (Max - 1): 06 if SList[i] > SList[i + 1]: 07 NoMoreSwaps = True 08 Temp = SList[i] 09 SList[i] = SList[i + 1] 10 SList[i + 1] = Temp B) Pascal/Delphi 01 PROCEDURE BubbleSort(VAR SList : ARRAY OF INTEGER; Max : INTEGER); 02 VAR NoMoreSwaps : BOOLEAN; i, Temp : INTEGER; 03 BEGIN 04 REPEAT 05 NoMoreSwaps := TRUE; 06 FOR i := 1 TO (Max – 1) 07 IF SList[i] > SList[i + 1] 08 THEN 09 BEGIN 10 NoMoreSwaps := TRUE; 11 Temp := SList[i]; 12 SList[i] := SList[i + 1]; 13 SList[i + 1] := Temp; 14 END; 15 UNTIL NoMoreSwaps; 16 END; C) Visual Basic 01 Sub BubbleSort(ByRef SList() As Integer, ByVal Max As Integer) 02 Dim NoMoreSwaps As Boolean, i, Temp As Integer 03 Do 04 NoMoreSwaps = True 05 For i : 0 To (Max – 1) 06 If SList(i) > SList(i + 1) Then 07 NoMoreSwaps = True 08 Temp = SList(i) 09 SList(i) = SList(i + 1) 10 SList(i + 1) = Temp 11 End If 12 Next 13 Loop Until (NoMoreSwaps = True) 14 End Sub

Question 17

The programming environment reported a syntax error in the BubbleSort code.

State the line number ........................................................................................................................

Write the correct code for this line.

...............................................................................................................................................[2]

Topic relevance

Why this question appears here

99% 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 9608_w16_qp_42.pdf

Keep practising this topic