Past-paper question · 2021 May-June · Paper 42 · Q2(c)

Question 2(c) 2021 · May-June · Paper 42 · 6 marks

Original past-paper question for 2(C)
Original past-paper question for 2(C)
Original past-paper question for 2(C)
Reveal official mark-scheme answer Official mark-scheme answer for 2(C)Official mark-scheme answer for 2(C)

Official answer for Question 2

Part (c)

Question 1

mark per bullet point

Question 6

  • Correct outer loop stop
  • Correct inner loop stop
  • Correct < in the IF
  • Correct theArray(y + 1)
  • Correct temp
  • Remainder matching pseudocode
✓
Example code:
✓
Visual Basic
✓
Sub bubbleSort()
✓
Dim temp As Integer = 0
✓
For x = 0 To 9
✓
For y = 0 To 8
✓
If theArray(y) < theArray(y + 1) Then
✓
temp = theArray(y)
✓
theArray(y) = theArray(y + 1)
✓
theArray(y + 1) = temp
✓
End If
✓
Next
✓
Next
✓
End Sub
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s21_ms_42.pdf →

Show text version of question

Question 2

Part (c)

Question 2

A program stores the following ten integers in a 1D array with the identifier arrayData.

Part (c)

The following bubble sort pseudocode algorithm sorts the data in theArray into descending

numerical order. There are five incomplete statements.

PROCEDURE bubbleSort()

DECLARE temp : INTEGER

FOR x 0 to …………………………………

FOR y 0 to …………………………………

IF theArray[y] ………………………………… theArray[y + 1] THEN

temp theArray[y]

theArray[y] …………………………………

theArray[y + 1] …………………………………

ENDIF

NEXT y

NEXT x

ENDPROCEDURE

Write program code for the procedure bubbleSort() to sort the data in arrayData into descending order.

Save your program.

Copy and paste the program code into part 2(c) in the evidence document.

[6]

Question 8

Topic relevance

Why this question appears here

82% 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 9618_s21_qp_42.pdf

Keep practising this topic