9618/43 · October/November 2025 · Worked solutions

Step-by-step solutions based on the mark scheme (not a mark-scheme dump).

Question 1

Paper page 2 for Q1
Original paper page 2

Part 1(a)(i) — solution

  1. Class header (and end where appropriate)
  2. Declaring Code as string and Value as integer
  3. Constructor header (and end where appropriate) within class …
  4. … taking two parameters …
  5. … assigning parameters to attributes

Visual Basic (VB.NET)

Public Class BoardObject
                     Private Code As String
                     Private Value As Integer
                     Sub New(pCode, pValue)
                          Code = pCode
                          Value = pValue
                     End Sub
                End Class

Python

class BoardObject():
                     def __init__(self, Code, Value):
                         self.Code = Code #string
                         self.Value = Value # integer

 University Press & Assessment 2025                       Page 7 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Class header (and end where appropriate)
  • Declaring Code as string and Value as integer
  • Constructor header (and end where appropriate) within class …
  • … taking two parameters …
  • … assigning parameters to attributes

Part 1(a)(ii) — solution

  1. 1 get header (and end where appropriate) with no parameter …
  2. … returning correct value without overriding
  3. 2nd correct get method

Visual Basic (VB.NET)

Function GetCode()
                    Return Code
                End Function

                Function GetValue()
                    Return Value
                End Function

Python

def GetCode(self):
                     return self.Code

                def GetValue(self):
                    return self.Value

 University Press & Assessment 2025                       Page 8 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • 1 get header (and end where appropriate) with no parameter …
  • … returning correct value without overriding
  • 2nd correct get method

Part 1(a)(iii) — solution

  1. Creating one instance of BoardObject and storing in correct variable …
  2. … with correct parameters
  3. Remaining four created correctly and stored

Visual Basic (VB.NET)

Dim Object1 As BoardObject = New BoardObject("A", 2)
                Dim Object2 As BoardObject = New BoardObject("B", 3)
                Dim Object3 As BoardObject = New BoardObject("C", 5)
                Dim Object4 As BoardObject = New BoardObject("D", 2)
                Dim Object5 As BoardObject = New BoardObject("E", 7)

Python

Object1 = BoardObject("A",2)
                Object2 = BoardObject("B",3)
                Object3 = BoardObject("C",5)
                Object4 = BoardObject("D",2)
                Object5 = BoardObject("E",7)

 University Press & Assessment 2025                       Page 9 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Creating one instance of BoardObject and storing in correct variable …
  • … with correct parameters
  • Remaining four created correctly and stored

Part 1(b)(i) — solution

  1. Class header (and end where appropriate)
  2. Constructor header (and end where appropriate) within class
  3. Declaration of 2D array with 10  10 elements of type BoardObject
  4. Storing BoardObject object with Code "-" and Value 0 in each array element

Visual Basic (VB.NET)

Public Class Board
                     Private TheBoard(9, 9) As BoardObject
                     Sub New()
                          For x = 0 To 9
                              For y = 0 To 9
                                  TheBoard(x, y) = New BoardObject("-", 0)
                              Next
                          Next
                     End Sub

                End Class

 University Press & Assessment 2025                       Page 10 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Class header (and end where appropriate)
  • Constructor header (and end where appropriate) within class
  • Declaration of 2D array with 10  10 elements of type BoardObject
  • Storing BoardObject object with Code "-" and Value 0 in each array element

Part 1(b)(i) — solution

  1. self.TheBoard = [] #type BoardObject
  2. TempList = []

Python

class Board():
                     def __init__(self):
                         self.TheBoard = [] #type BoardObject
                         for x in range(10):
                             TempList = []
                             for y in range(10):
                                 TempList.append(BoardObject("-",0))
                             self.TheBoard.append(TempList)

Mark points

  • self.TheBoard = [] #type BoardObject
  • TempList = []

Part 1(b)(ii) — solution

  1. Get method header taking 2 (integer) parameters …
  2. … returning the BoardObject at Board position of parameters

Visual Basic (VB.NET)

Function GetObject(Rowpos, Columnpos)
                     Return TheBoard(Rowpos, Columnpos)
                 End Function

Python

def GetObject(self, Rowpos, Columnpos):
                        return self.TheBoard[Rowpos][Columnpos]

 University Press & Assessment 2025                       Page 11 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Get method header taking 2 (integer) parameters …
  • … returning the BoardObject at Board position of parameters

Part 1(b)(iii) — solution

  1. Set method header taking three parameters (TheObject, row, column) …
  2. … storing parameter TheObject in TheBoard at parameters row and column

Visual Basic (VB.NET)

Sub SetObject(TheObject, Rowpos, Columnpos)
                     TheBoard(Rowpos, Columnpos) = TheObject
                End Sub

Python

def SetObject(self, TheObject, Rowpos, Columnpos):
                        self.TheBoard[Rowpos][Columnpos] = TheObject

 University Press & Assessment 2025                       Page 12 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Set method header taking three parameters (TheObject, row, column) …
  • … storing parameter TheObject in TheBoard at parameters row and column

Part 1(b)(iv) — solution

  1. Method DisplayBoard() header (and end where appropriate) and using GetCode()
  2. Outputting Code of all BoardObject elements in both indices (10  10)
  3. … with each row on one line and space between each value

Visual Basic (VB.NET)

Sub DisplayBoard()
                    Dim OutputLine As String
                    For x = 0 To 9
                        OutputLine = ""
                        For y = 0 To 9
                            OutputLine = OutputLine & TheBoard(x, y).GetCode() & " "
                        Next
                        Console.WriteLine(OutputLine)
                    Next
                End Sub

 University Press & Assessment 2025                       Page 13 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Method DisplayBoard() header (and end where appropriate) and using GetCode()
  • Outputting Code of all BoardObject elements in both indices (10  10)
  • … with each row on one line and space between each value

Part 1(b)(iv) — solution

  1. OutputLine = ""
  2. OutputLine = OutputLine + str(self.TheBoard[x][y].GetCode()) + " "

Python

def DisplayBoard(self):

                             for x in range(10):
                                 OutputLine = ""
                                 for y in range(10):
                                     OutputLine = OutputLine + str(self.TheBoard[x][y].GetCode()) + " "
                                 print(OutputLine)

 University Press & Assessment 2025                       Page 14 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • OutputLine = ""
  • OutputLine = OutputLine + str(self.TheBoard[x][y].GetCode()) + " "

Part 1(c)(i) — solution

  1. Creating instance of Board and storing it
  2. Storing all 5 objects in correct positions
  3. Calling DisplayBoard()

Visual Basic (VB.NET)

Dim GameBoard As Board = New Board()
                 Dim Object1 As BoardObject = New BoardObject("A", 2)
                 Dim Object2 As BoardObject = New BoardObject("B", 3)
                 Dim Object3 As BoardObject = New BoardObject("C", 5)
                 Dim Object4 As BoardObject = New BoardObject("D", 2)
                 Dim Object5 As BoardObject = New BoardObject("E", 7)

                 GameBoard.SetObject(Object1, 0, 0)
                 GameBoard.SetObject(Object2, 9, 9)
                 GameBoard.SetObject(Object3, 4, 5)
                 GameBoard.SetObject(Object4, 2, 2)
                 GameBoard.SetObject(Object5, 8, 7)
                 GameBoard.DisplayBoard()

 University Press & Assessment 2025                       Page 15 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Creating instance of Board and storing it
  • Storing all 5 objects in correct positions
  • Calling DisplayBoard()

Part 1(c)(i) — solution

  1. GameBoard = Board()
  2. Object1 = BoardObject("A",2)
  3. Object2 = BoardObject("B",3)
  4. Object3 = BoardObject("C",5)
  5. Object4 = BoardObject("D",2)
  6. Object5 = BoardObject("E",7)

Python

GameBoard = Board()
                Object1 = BoardObject("A",2)
                Object2 = BoardObject("B",3)
                Object3 = BoardObject("C",5)
                Object4 = BoardObject("D",2)
                Object5 = BoardObject("E",7)
                GameBoard.SetObject(Object1, 0, 0)
                GameBoard.SetObject(Object2, 9, 9)
                GameBoard.SetObject(Object3, 4, 5)
                GameBoard.SetObject(Object4, 2, 2)
                GameBoard.SetObject(Object5, 8, 7)
                GameBoard.DisplayBoard()

Mark points

  • GameBoard = Board()
  • Object1 = BoardObject("A",2)
  • Object2 = BoardObject("B",3)
  • Object3 = BoardObject("C",5)
  • Object4 = BoardObject("D",2)
  • Object5 = BoardObject("E",7)

Part 1(c)(ii) — solution

1 mark for screenshot showing board contents 1 Example University Press & Assessment 2025 Page 16 of 39 9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2025

Mark points

  • Include the ideas shown in the solution above.

Part 1(d)(i) — solution

  1. Taking x-axis and y-axis as input repeatedly until each value is between 0 and 9 (inclusive)
  2. Calling Board.GetObject() with input x-axis and y-axis values …
  3. … checking if object exists e.g. if Code is "-"
  4. … outputting "Miss" if no BoardObject and outputting Code and Value in an appropriate message if there is a

Visual Basic (VB.NET)

Dim InputRow, InputColumn As Integer
                InputRow = -1
                InputColumn = -1
                While InputRow < 0 Or InputRow > 9
                     Console.WriteLine("Enter the row position between 0 and 9 ")
                     InputRow = Console.ReadLine()
                End While

 University Press & Assessment 2025                       Page 17 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Taking x-axis and y-axis as input repeatedly until each value is between 0 and 9 (inclusive)
  • Calling Board.GetObject() with input x-axis and y-axis values …
  • … checking if object exists e.g. if Code is "-"
  • … outputting "Miss" if no BoardObject and outputting Code and Value in an appropriate message if there is a

Part 1(d)(i) — solution

  1. InputColumn = Console.ReadLine()
  2. Dim GuessObject As BoardObject = GameBoard.GetObject(InputRow, InputColumn)
  3. If GuessObject.GetCode() = "-" Then
  4. InputRow = -1
  5. InputRow = int(input("Enter the row position between 0 and 9 "))
  6. InputColumn = -1
  7. InputColumn = int(input("Enter the column position between 0 and 9 "))
  8. GuessObject = GameBoard.GetObject(InputRow, InputColumn)
  9. if GuessObject.GetCode() == "-":

Python

InputRow = -1
                while InputRow < 0 or InputRow > 9:
                     InputRow = int(input("Enter the row position between 0 and 9 "))

                InputColumn = -1
                while InputColumn < 0 or InputColumn > 9:
                    InputColumn = int(input("Enter the column position between 0 and 9 "))

                GuessObject = GameBoard.GetObject(InputRow, InputColumn)
                if GuessObject.GetCode() == "-":
                    print("Miss")
                else:
                    print("You found " + str(GuessObject.GetCode()) + " with value " +
                str(GuessObject.GetValue()))

 University Press & Assessment 2025                       Page 18 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • InputColumn = Console.ReadLine()
  • Dim GuessObject As BoardObject = GameBoard.GetObject(InputRow, InputColumn)
  • If GuessObject.GetCode() = "-" Then
  • InputRow = -1
  • InputRow = int(input("Enter the row position between 0 and 9 "))
  • InputColumn = -1
  • InputColumn = int(input("Enter the column position between 0 and 9 "))
  • GuessObject = GameBoard.GetObject(InputRow, InputColumn)
  • if GuessObject.GetCode() == "-":

Part 1(d)(ii) — solution

1 mark for screenshot showing inputs and correct output 1 Row 10 4 Column -1 5 Output C 5 Example University Press & Assessment 2025 Page 19 of 39 9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2025

Mark points

  • Include the ideas shown in the solution above.

Question 2

Paper page 9 for Q2
Original paper page 9

Part 2(a) — solution

  1. Queue declared as a (global) 1D array of 100 string elements all initialised to ""
  2. QueueHead and QueueTail initialised with –1, NumberItems initialised to 0

Visual Basic (VB.NET)

Dim Queue(99) As String
                    Dim QueueHead As Integer
                    Dim QueueTail As Integer
                    Dim NumberItems As Integer
                For x = 0 To 99
                      Queue(x) = ""
                 Next
                 QueueHead = -1
                 QueueTail = -1
                 NumberItems = 0

 University Press & Assessment 2025                       Page 20 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Queue declared as a (global) 1D array of 100 string elements all initialised to ""
  • QueueHead and QueueTail initialised with –1, NumberItems initialised to 0

Part 2(a) — solution

  1. Queue = []
  2. QueueHead = -1
  3. QueueTail = -1
  4. NumberItems = 0

Python

global Queue, QueueHead, QueueTail, NumberItems
                Queue = []
                     for x in range(100):
                         Queue.append("")
                     QueueHead = -1
                     QueueTail = -1
                     NumberItems = 0

 University Press & Assessment 2025                       Page 21 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme                October/November 2025

Mark points

  • Queue = []
  • QueueHead = -1
  • QueueTail = -1
  • NumberItems = 0

Part 2(b) — solution

  1. Function header (and end where appropriate) taking one (string) parameter and checking full and returning FALSE
  2. (otherwise) Storing parameter in QueueTail + 1
  3. Incrementing QueueTail and NumberItems
  4. (Dealing with first element) If QueueHead = –1 store 0 in QueueHead / increment QueueHead
  5. Return TRUE in all cases when inserted

Mark points

  • Function header (and end where appropriate) taking one (string) parameter and checking full and returning FALSE
  • (otherwise) Storing parameter in QueueTail + 1
  • Incrementing QueueTail and NumberItems
  • (Dealing with first element) If QueueHead = –1 store 0 in QueueHead / increment QueueHead
  • Return TRUE in all cases when inserted

Part 2(b) — solution

  1. If QueueHead = -1 Then
  2. Queue(0) = TheData
  3. QueueHead = 0
  4. QueueTail = 0
  5. NumberItems += 1
  6. ElseIf QueueTail >= 99 Then
  7. Queue(QueueTail + 1) = TheData
  8. QueueTail += 1
  9. NumberItems += 1
  10. if(QueueHead == -1){
  11. Queue[0] = TheData
  12. QueueHead = 0
  13. QueueTail = 0
  14. NumberItems +=1
  15. elif QueueTail >= 99:
  16. Queue[QueueTail+1] = TheData
  17. QueueTail +=1
  18. NumberItems +=1

Visual Basic (VB.NET)

Function Enqueue(TheData)
                    If QueueHead = -1 Then
                        Queue(0) = TheData
                        QueueHead = 0
                        QueueTail = 0
                        NumberItems += 1
                        Return True
                    ElseIf QueueTail >= 99 Then
                        Queue(QueueTail + 1) = TheData
                        QueueTail += 1
                        NumberItems += 1
                        Return True
                    Else
                        Return False
                    End If
                End Function

Python

def Enqueue(TheData):
                     global Queue, QueueHead, QueueTail, NumberItems
                     if(QueueHead == -1){
                           Queue[0] = TheData
                           QueueHead = 0
                           QueueTail = 0
                           NumberItems +=1
                           return True
                     elif QueueTail >= 99:
                         Queue[QueueTail+1] = TheData
                         QueueTail +=1
                         NumberItems +=1
                         return True
                     else:
                         return False

 University Press & Assessment 2025                       Page 23 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme          October/November 2025

Mark points

  • If QueueHead = -1 Then
  • Queue(0) = TheData
  • QueueHead = 0
  • QueueTail = 0
  • NumberItems += 1
  • ElseIf QueueTail >= 99 Then
  • Queue(QueueTail + 1) = TheData
  • QueueTail += 1
  • NumberItems += 1
  • if(QueueHead == -1){
  • Queue[0] = TheData
  • QueueHead = 0
  • QueueTail = 0
  • NumberItems +=1
  • elif QueueTail >= 99:
  • Queue[QueueTail+1] = TheData
  • QueueTail +=1
  • NumberItems +=1

Part 2(c) — solution

  1. Function header (and end), checking if Queue is empty (NumberItems = 0 or QueueHead > QueueTail) and
  2. (otherwise) returning Queue[QueueHead]
  3. Incrementing QueueHead, decrementing NumberItems

Visual Basic (VB.NET)

Function Dequeue()

                      If NumberItems = 0 Then
                          Return "False"
                      Else
                          Dequeue = Queue(QueueHead)
                          QueueHead += 1
                          NumberItems -= 1

                    End If
                End Function

 University Press & Assessment 2025                       Page 24 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Function header (and end), checking if Queue is empty (NumberItems = 0 or QueueHead > QueueTail) and
  • (otherwise) returning Queue[QueueHead]
  • Incrementing QueueHead, decrementing NumberItems

Part 2(c) — solution

  1. if NumberItems == 0:
  2. ReturnData = Queue[QueueHead]
  3. QueueHead += 1
  4. NumberItems -=1

Python

def Dequeue():
                     global Queue, QueueHead, QueueTail, NumberItems
                     if NumberItems == 0:
                         return "False"
                     else:
                         ReturnData = Queue[QueueHead]
                         QueueHead += 1
                         NumberItems -=1
                         return ReturnData

 University Press & Assessment 2025                       Page 25 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme           October/November 2025

Mark points

  • if NumberItems == 0:
  • ReturnData = Queue[QueueHead]
  • QueueHead += 1
  • NumberItems -=1

Part 2(d) — solution

  1. Procedure header (and end where appropriate)
  2. Opening the file and closing the file (in appropriate place)
  3. Looping until EOF // looping through each line …
  4. … read in each value …
  5. … calling Enqueue() with read in value and store/use return value
  6. Exception handling with try except and appropriate output with all file access within try

Mark points

  • Procedure header (and end where appropriate)
  • Opening the file and closing the file (in appropriate place)
  • Looping until EOF // looping through each line …
  • … read in each value …
  • … calling Enqueue() with read in value and store/use return value
  • Exception handling with try except and appropriate output with all file access within try

Part 2(d) — solution

  1. Dim FinishLoop As Boolean = True
  2. Do Until DataReader.EndOfStream Or FinishLoop = False
  3. ReturnValue = Enqueue(DataReader.ReadLine())
  4. If ReturnValue = False Then
  5. FinishLoop = False
  6. TheFile = open("BinaryData.txt")
  7. ReturnValue = Enqueue(Line.strip())
  8. if ReturnValue == False:

Visual Basic (VB.NET)

Sub ReadData()
                     Dim ReturnValue As String
                     Dim DataReader As New System.IO.StreamReader("BinaryData.txt")
                     Dim FinishLoop As Boolean = True
                     Do Until DataReader.EndOfStream Or FinishLoop = False
                          ReturnValue = Enqueue(DataReader.ReadLine())
                          If ReturnValue = False Then
                              FinishLoop = False
                          End If
                     Loop
                     DataReader.Close()
                 End Sub

Python

def ReadData():

                      TheFile = open("BinaryData.txt")
                      for Line in TheFile:
                          ReturnValue = Enqueue(Line.strip())
                          if ReturnValue == False:
                              break

                      TheFile.close()

 University Press & Assessment 2025                       Page 27 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme                   October/November 2025

Mark points

  • Dim FinishLoop As Boolean = True
  • Do Until DataReader.EndOfStream Or FinishLoop = False
  • ReturnValue = Enqueue(DataReader.ReadLine())
  • If ReturnValue = False Then
  • FinishLoop = False
  • TheFile = open("BinaryData.txt")
  • ReturnValue = Enqueue(Line.strip())
  • if ReturnValue == False:

Part 2(e) — solution

  1. Procedure header (and end where appropriate), storing final string compressed data in global variable
  2. Call Dequeue() and storing return value …
  3. … repeatedly until the return value == "False"
  4. Comparing new value with previous …
  5. … maintaining counter of number of occurrences …
  6. … appending digit and number of occurrences to a string without overriding

Mark points

  • Procedure header (and end where appropriate), storing final string compressed data in global variable
  • Call Dequeue() and storing return value …
  • … repeatedly until the return value == "False"
  • Comparing new value with previous …
  • … maintaining counter of number of occurrences …
  • … appending digit and number of occurrences to a string without overriding

Part 2(e) — solution

  1. Dim First As String = Dequeue()
  2. Dim NewLine As String = ""
  3. Count = 1
  4. NextChar = Dequeue()
  5. While NextChar = First
  6. Count += 1
  7. First = NextChar
  8. NextChar = Dequeue()
  9. NewLine = First & Count
  10. NewString = NewString & NewLine
  11. First = NextChar
  12. First = Dequeue()
  13. NewString = ""
  14. while NumberItems > 0 and First != "False":
  15. Count = 1
  16. NextChar = Dequeue()
  17. while NextChar == First:
  18. Count += 1
  19. First = NextChar
  20. NextChar = Dequeue()

Visual Basic (VB.NET)

Sub Compress()
                     Dim First As String = Dequeue()
                     Dim NewLine As String = ""
                     Dim Count As Integer
                     Dim NextChar As String
                     While NumberItems > 0 And First <> "False"
                         Count = 1
                         NextChar = Dequeue()

                              While NextChar = First
                                  Count += 1
                                  First = NextChar
                                  NextChar = Dequeue()
                              End While

                            NewLine = First & Count
                            NewString = NewString & NewLine
                            First = NextChar
                        End While

Python

def Compress():
                     global NewString
                     First = Dequeue()
                     NewString = ""
                     while NumberItems > 0 and First != "False":
                         Count = 1
                         NextChar = Dequeue()
                         while NextChar == First:
                             Count += 1
                             First = NextChar
                             NextChar = Dequeue()
                         NewLine = First + str(Count)
                         NewString = NewString + NewLine
                         First = NextChar

 University Press & Assessment 2025                       Page 29 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Dim First As String = Dequeue()
  • Dim NewLine As String = ""
  • Count = 1
  • NextChar = Dequeue()
  • While NextChar = First
  • Count += 1
  • First = NextChar
  • NextChar = Dequeue()
  • NewLine = First & Count
  • NewString = NewString & NewLine
  • First = NextChar
  • First = Dequeue()
  • NewString = ""
  • while NumberItems > 0 and First != "False":
  • Count = 1
  • NextChar = Dequeue()
  • while NextChar == First:
  • Count += 1
  • First = NextChar
  • NextChar = Dequeue()

Part 2(f)(i) — solution

  1. Calling ReadData() then Compress()
  2. Outputting compressed string

Visual Basic (VB.NET)

Sub Main()
                     NewString = ""
                     For x = 0 To 99
                       Queue(x) = ""
                     Next
                     QueueHead = -1
                     QueueTail = -1
                     NumberItems = 0

                     ReadData()
                     Compress()
                     Console.WriteLine(NewString)
                     Console.ReadLine()
                 End Sub

 University Press & Assessment 2025                       Page 30 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Calling ReadData() then Compress()
  • Outputting compressed string

Part 2(f)(i) — solution

  1. NewString = ""
  2. Queue = []
  3. QueueHead = -1
  4. QueueTail = -1
  5. NumberItems = 0

Python

NewString = ""
                Queue = []
                for x in range(100):
                        Queue.append("")
                QueueHead = -1
                QueueTail = -1
                NumberItems = 0
                ReadData()
                Compress()
                print(NewString)

Mark points

  • NewString = ""
  • Queue = []
  • QueueHead = -1
  • QueueTail = -1
  • NumberItems = 0

Part 2(f)(ii) — solution

1 mark for screenshot showing output 1 Example University Press & Assessment 2025 Page 31 of 39 9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2025

Mark points

  • Include the ideas shown in the solution above.

Question 3

Paper page 12 for Q3
Original paper page 12

Part 3(a)(i) — solution

  1. Function header (and end) taking three parameters
  2. Checking number of elements for 0 and returning 0 (e.g. ArrayCopy = [] // len(ArrayCopy) == 0)
  3. (otherwise) comparing first array element to parameter DataToFind …
  4. … if match return recursive call adding 1
  5. … if no match return recursive call without adding 1
  6. … all recursive calls have array without first element, NumberElements-1 and DataToFind

Mark points

  • Function header (and end) taking three parameters
  • Checking number of elements for 0 and returning 0 (e.g. ArrayCopy = [] // len(ArrayCopy) == 0)
  • (otherwise) comparing first array element to parameter DataToFind …
  • … if match return recursive call adding 1
  • … if no match return recursive call without adding 1
  • … all recursive calls have array without first element, NumberElements-1 and DataToFind

Part 3(a)(i) — solution

  1. For x = 1 To NumberElements - 1
  2. NewArray(x - 1) = ArrayCopy(x)
  3. If ArrayCopy(0) = DataToFind Then
  4. NewArray = ArrayCopy[1:]
  5. if ArrayCopy[0] == DataToFind:

Visual Basic (VB.NET)

Function RecursiveCount(DataToFind As Integer, ArrayCopy() As Integer, NumberElements As
                Integer)

                      If NumberElements > 0 Then
                          Dim NewArray(NumberElements - 1) As Integer
                          For x = 1 To NumberElements - 1
                              NewArray(x - 1) = ArrayCopy(x)
                          Next x

                             If ArrayCopy(0) = DataToFind Then
                                 Return 1 + RecursiveCount(DataToFind, NewArray, NumberElements - 1)
                             Else
                                 Return RecursiveCount(DataToFind, NewArray, NumberElements - 1)

                          End If
                      Else
                          Return 0

                    End If
                End Function

Python

def RecursiveCount(DataToFind, ArrayCopy, NumberElements):
                     if NumberElements > 0:
                         NewArray = ArrayCopy[1:]
                         if ArrayCopy[0] == DataToFind:
                             return 1 + RecursiveCount(DataToFind, NewArray, NumberElements - 1)
                         else:
                             return RecursiveCount(DataToFind, NewArray, NumberElements - 1)
                     else:
                         return 0

 University Press & Assessment 2025                       Page 33 of 39

9618/43                                           Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • For x = 1 To NumberElements - 1
  • NewArray(x - 1) = ArrayCopy(x)
  • If ArrayCopy(0) = DataToFind Then
  • NewArray = ArrayCopy[1:]
  • if ArrayCopy[0] == DataToFind:

Part 3(a)(ii) — solution

  1. Storing the correct data in an array
  2. Calling RecursiveCount() with the correct parameters
  3. Outputting the return value

Visual Basic (VB.NET)

Dim MyArray() As Integer = {0, 5, 1, 2, 5, 9, 9, 6, 5, 0}

                Console.WriteLine(RecursiveCount(0, MyArray, 10))

Python

MyArray = [0,5,1,2,5,9,9,6,5,0]
                print(RecursiveCount(0, MyArray, 10))

Mark points

  • Storing the correct data in an array
  • Calling RecursiveCount() with the correct parameters
  • Outputting the return value

Part 3(a)(iii) — solution

1 mark for screenshot showing correct output of 2 1 Example

Mark points

  • Include the ideas shown in the solution above.

Part 3(b)(i) — solution

  1. Dim Code As String = "x=0;y=1;x=x+y;y++;"
  2. Code = "x=0;y=1;x=x+y;y++;"

Visual Basic (VB.NET)

Dim Code As String = "x=0;y=1;x=x+y;y++;"

Python

Code = "x=0;y=1;x=x+y;y++;"

 University Press & Assessment 2025                        Page 34 of 39

9618/43                                            Cambridge International AS & A Level – Mark Scheme      October/November 2025

Mark points

  • Dim Code As String = "x=0;y=1;x=x+y;y++;"
  • Code = "x=0;y=1;x=x+y;y++;"

Part 3(b)(ii) — solution

  1. Function header, taking one string parameter
  2. Loop e.g. four times/through each character in parameter
  3. Comparing character from parameter to ';' …
  4. … concatenate current character to a string until ';' is found
  5. … when ';' found storing string in array
  6. Returning string array without semicolons

Mark points

  • Function header, taking one string parameter
  • Loop e.g. four times/through each character in parameter
  • Comparing character from parameter to ';' …
  • … concatenate current character to a string until ';' is found
  • … when ';' found storing string in array
  • Returning string array without semicolons

Part 3(b)(ii) — solution

  1. Dim Count As Integer = 0
  2. Dim TempString As String = ""
  3. Dim Character As String = ""
  4. Dim LastElement As Integer = 0
  5. For x = 0 To 3
  6. TempString = ""
  7. Character = DataString(Count)
  8. TempString = TempString + Character
  9. Count = Count + 1
  10. Character = DataString(Count)
  11. SplitDataArray(LastElement) = TempString
  12. LastElement = LastElement + 1
  13. Count = Count + 1

Visual Basic (VB.NET)

Function SplitData(DataString)
                     Dim SplitDataArray(10) As String
                     Dim Count As Integer = 0
                     Dim TempString As String = ""
                     Dim Character As String = ""
                     Dim LastElement As Integer = 0

                        For x = 0 To 3
                            TempString = ""
                            Try
                                Character = DataString(Count)

                                     While Character <> ";"
                                         TempString = TempString + Character
                                         Count = Count + 1
                                         Character = DataString(Count)

                                     End While

                                   SplitDataArray(LastElement) = TempString
                                   LastElement = LastElement + 1
                               Catch
                                   Console.WriteLine("No more character")
                               End Try
                               Count = Count + 1
                        Next

                     Return SplitDataArray
                 End Function

 University Press & Assessment 2025                       Page 36 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Dim Count As Integer = 0
  • Dim TempString As String = ""
  • Dim Character As String = ""
  • Dim LastElement As Integer = 0
  • For x = 0 To 3
  • TempString = ""
  • Character = DataString(Count)
  • TempString = TempString + Character
  • Count = Count + 1
  • Character = DataString(Count)
  • SplitDataArray(LastElement) = TempString
  • LastElement = LastElement + 1
  • Count = Count + 1

Part 3(b)(ii) — solution

  1. SplitDataArray = []
  2. Count = 0
  3. TempString = ""
  4. Character = DataString[Count]
  5. while Character != ";":
  6. TempString = TempString + (Character)
  7. Count += 1
  8. Character = DataString[Count]
  9. Count += 1

Python

def SplitData(DataString):
                     SplitDataArray = []
                     Count = 0
                     for x in range(4):
                         TempString = ""
                         try:
                             Character = DataString[Count]
                             while Character != ";":
                                 TempString = TempString + (Character)
                                 Count += 1
                                 Character = DataString[Count]
                             SplitDataArray.append(TempString)
                         except:
                             print("No more characters")
                         Count += 1
                     return SplitDataArray

 University Press & Assessment 2025                       Page 37 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • SplitDataArray = []
  • Count = 0
  • TempString = ""
  • Character = DataString[Count]
  • while Character != ";":
  • TempString = TempString + (Character)
  • Count += 1
  • Character = DataString[Count]
  • Count += 1

Part 3(b)(iii) — solution

  1. Calling SplitData() with array as argument and storing/using return value
  2. Outputting each element of the returned array on a new line

Visual Basic (VB.NET)

Dim Code As String = "x=0;y=1;x=x+y;y++;"
                 Dim SplitDataArray() As String = SplitData(Code)

                 For x = 0 To 3
                      Console.WriteLine(SplitDataArray(x))
                 Next

Python

Code = "x=0;y=1;x=x+y;y++;"
                SplitDataArray = SplitData(Code)
                for x in range(4):
                     print(SplitDataArray[x])

 University Press & Assessment 2025                       Page 38 of 39

9618/43                                          Cambridge International AS & A Level – Mark Scheme   October/November 2025

Mark points

  • Calling SplitData() with array as argument and storing/using return value
  • Outputting each element of the returned array on a new line

Part 3(b)(iv) — solution

  1. x=x+y

Mark points

  • x=x+y