Question 1
Part 1(a) — solution
- Declaration of array with space for 9 strings (through declaration/initialisation)
- Storing the correct data in the order given
Visual Basic (VB.NET)
Dim TheData(8) As String
TheData(0) = "laptop"
TheData(1) = "tablet"
TheData(2) = "printer"
TheData(3) = "computer"
TheData(4) = "processor"
TheData(5) = "monitor"
TheData(6) = "memory"
TheData(7) = "cable"
TheData(8) = "touchscreen"
Python
TheData = ["laptop", "tablet", "printer", "computer", "processor", "monitor", "memory", "cable",
"touchscreen"]
Mark points
- Declaration of array with space for 9 strings (through declaration/initialisation)
- Storing the correct data in the order given
Part 1(b)(i) — solution
- Procedure header (and end where appropriate) taking one (string array) parameter
- Looping through each string in the array
- Finding the shortest string
- Finding the longest string
- Output the longest and shortest string in appropriate messages
Visual Basic (VB.NET)
Sub FindLongestShortest(TheData())
Dim LongestLength As Integer = -1
Dim LongestWord As String = ""
Dim ShortestLength As Integer = 999
Dim ShortestWord As String = ""
For x = 0 To TheData.Length() - 1
If Len(TheData(x)) > LongestLength Then
LongestLength = Len(TheData(x))
LongestWord = TheData(x)
End If
If Len(TheData(x)) < ShortestLength Then
ShortestLength = Len(TheData(x))
ShortestWord = TheData(x)
End If
Next
University Press & Assessment 2026 Page 8 of 41
Trace ID: PC-AB1FFDFB16
Re-uploading, mirroring or re-hosting this file on any other website or domain is unauthorised and traceable.
Licensed for hosting on papacambridge.com only.
PapaCambridge
9618/42 Mark Scheme June · papacambridge.com
2026 | Source: papacambridge.com 9618/42 Mark Scheme June 2026
Downloaded from PapaCambridge - https://papacambridge.com/
9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2026
Guidance
Console.WriteLine("The longest word is " & LongestWord)
Console.WriteLine("The shortest word is " & ShortestWord)
End Sub
Python
def FindLongestShortest(TheData):
LongestLength = -1
LongestWord = ""
ShortestLength = 999999999
ShortestWord = ""
for x in range(len(TheData)):
if len(TheData[x]) > LongestLength:
LongestLength = len((TheData[x]))
LongestWord = TheData[x]
if len(TheData[x]) < ShortestLength:
ShortestLength = len(TheData[x])
ShortestWord = TheData[x]
print("The longest word is", LongestWord)
print("The shortest word is", ShortestWord)
Mark points
- Procedure header (and end where appropriate) taking one (string array) parameter
- Looping through each string in the array
- Finding the shortest string
- Finding the longest string
- Output the longest and shortest string in appropriate messages
Part 1(b)(ii) — solution
- calling FindLongestShortest with array as parameter
Visual Basic (VB.NET)
FindLongestShortest(TheData)
Python
FindLongestShortest(TheData)
Mark points
- calling FindLongestShortest with array as parameter
Part 1(b)(iii) — solution
Mark points
- Include the ideas shown in the solution above.
Part 1(c)(i) — solution
- Function header (and end where appropriate) taking (string array) parameter
- Looping through each element in the array…
- …using insertion sort method e.g. taking element out and moving down
- Using appropriate string comparison function/methods
- Returning a correctly sorted array
Visual Basic (VB.NET)
Function InsertionSort(TheData())
Dim ArrayLength As Integer = TheData.Length()
Dim Temp As String
Dim y As Integer
If ArrayLength <= 1 Then
Return TheData
End If
For x = 1 To ArrayLength - 1
Temp = TheData(x)
y = x - 1
While y >= 0
If Temp < TheData(y) Then
TheData(y + 1) = TheData(y)
y = y - 1
Else
Exit While
End If
End While
TheData(y + 1) = Temp
University Press & Assessment 2026 Page 11 of 41
Trace ID: PC-AB1FFDFB16
Re-uploading, mirroring or re-hosting this file on any other website or domain is unauthorised and traceable.
Licensed for hosting on papacambridge.com only.
PapaCambridge
9618/42 Mark Scheme June · papacambridge.com
2026 | Source: papacambridge.com 9618/42 Mark Scheme June 2026
Downloaded from PapaCambridge - https://papacambridge.com/
9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2026
Guidance
Next
Return TheData
End Function
Python
def InsertionSort(TheData):
ArrayLength = len(TheData)
if ArrayLength <= 1:
return TheData
for x in range(1, ArrayLength):
Temp = TheData[x]
y = x-1
while y >= 0 and Temp < TheData[y]:
TheData[y+1] = TheData[y]
y -= 1
TheData[y+1] = Temp
return TheData
Mark points
- Function header (and end where appropriate) taking (string array) parameter
- Looping through each element in the array…
- …using insertion sort method e.g. taking element out and moving down
- Using appropriate string comparison function/methods
- Returning a correctly sorted array
Part 1(c)(ii) — solution
- Outputting "Before sorting" and the array contents before sorting
- Calling InsertionSort() with array and storing/using returned array
- Outputting "After sorting" and the array contents after sorting
Visual Basic (VB.NET)
Console.WriteLine("Before sorting")
For x = 0 To 8
Console.WriteLine(TheData(x))
Next
Console.WriteLine("After sorting")
TheData = InsertionSort(TheData)
For x = 0 To 8
Console.WriteLine(TheData(x))
Next
Python
print("Before Sorting")
print(TheData)
print("After sorting")
TheData = InsertionSort(TheData)
print(TheData)
Mark points
- Outputting "Before sorting" and the array contents before sorting
- Calling InsertionSort() with array and storing/using returned array
- Outputting "After sorting" and the array contents after sorting
Part 1(c)(iii) — solution
Mark points
- Include the ideas shown in the solution above.
Part 1 — solution
Mark points
- Include the ideas shown in the solution above.