9618/41 · 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) — solution

  1. (Global) 1D array initialised with 30 null values
  2. (Global) TopofStack initialised with –1

Visual Basic (VB.NET)

Dim Stack(29) As Integer
                 Dim TopOfStack As Integer
                Sub Main(args As String())
                   For x = 0 To 29
                       Stack(x) = Nothing
                   Next
                   TopOfStack = -1
                End Sub

Python

Stack = [None for x in range(30)]
                TopOfStack = -1

 University Press & Assessment 2025                        Page 6 of 36

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

Mark points

  • (Global) 1D array initialised with 30 null values
  • (Global) TopofStack initialised with –1

Part 1(b) — solution

  1. Function header (and end) taking one parameter, returning Boolean in all instances
  2. Checking if stack is full (TopOfStack = 29) and, if it is, returning FALSE
  3. Incrementing TopofStack
  4. (Otherwise) Storing parameter in incremented TopOfStack position and returning TRUE

Visual Basic (VB.NET)

Function Push(DataToPush)
                    If TopOfStack < 29 Then
                        TopOfStack = TopOfStack + 1
                        Stack(TopOfStack) = DataToPush
                        Return True
                    End If
                    Return False
                End Function

 University Press & Assessment 2025                       Page 7 of 36

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

Mark points

  • Function header (and end) taking one parameter, returning Boolean in all instances
  • Checking if stack is full (TopOfStack = 29) and, if it is, returning FALSE
  • Incrementing TopofStack
  • (Otherwise) Storing parameter in incremented TopOfStack position and returning TRUE

Part 1(b) — solution

  1. TopOfStack = TopOfStack + 1
  2. Stack[TopOfStack] = DataToPush

Python

def Push(DataToPush):
                     global Stack
                     global TopOfStack
                     if TopOfStack < 29:
                         TopOfStack = TopOfStack + 1
                         Stack[TopOfStack] = DataToPush
                         return True
                     else:
                         return False

 University Press & Assessment 2025                       Page 8 of 36

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

Mark points

  • TopOfStack = TopOfStack + 1
  • Stack[TopOfStack] = DataToPush

Part 1(c) — solution

  1. Function header (and end) returning integer in all cases
  2. Checking if stack empty (TopofStack = –1) and returning -999 when true
  3. (Otherwise) Accessing and returning item at TopOfStack (before it's decremented)
  4. Decrementing TopofStack

Visual Basic (VB.NET)

Function Pop()
                    If TopOfStack = -1 Then
                        Return -999
                    Else
                         Dim DataReturn As Integer = Stack(TopOfStack)
                         TopOfStack = TopOfStack - 1
                         Return DataReturn
                     End If
                End Function

 University Press & Assessment 2025                       Page 9 of 36

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

Mark points

  • Function header (and end) returning integer in all cases
  • Checking if stack empty (TopofStack = –1) and returning -999 when true
  • (Otherwise) Accessing and returning item at TopOfStack (before it's decremented)
  • Decrementing TopofStack

Part 1(c) — solution

  1. if TopOfStack == -1:
  2. DataReturn = Stack[TopOfStack]
  3. TopOfStack = TopOfStack - 1

Python

def Pop():
                     global Stack
                     global TopOfStack
                     if TopOfStack == -1:
                         return -999
                     else:
                         DataReturn = Stack[TopOfStack]
                         TopOfStack = TopOfStack - 1
                         return DataReturn

 University Press & Assessment 2025                       Page 10 of 36

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

Mark points

  • if TopOfStack == -1:
  • DataReturn = Stack[TopOfStack]
  • TopOfStack = TopOfStack - 1

Part 1(d) — solution

  1. Looping 40 times
  2. Generating random number between 0 and 1000 inclusive inside the loop
  3. Calling Push() with each random number and storing/using return value … … if return value is FALSE output Stack

Visual Basic (VB.NET)

For x = 0 To 39
                    Pushed = Push(RandomNumber.Next(0, 1000))
                    If Pushed = False Then
                       Console.WriteLine("Stack full")
                       x = 40
                    End If
                Next

Python

for x in range(40):
                     Pushed = Push(random.randint(0,1000))
                     if Pushed == False:
                         print("Stack full")
                         break

 University Press & Assessment 2025                       Page 11 of 36

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

Mark points

  • Looping 40 times
  • Generating random number between 0 and 1000 inclusive inside the loop
  • Calling Push() with each random number and storing/using return value … … if return value is FALSE output Stack

Part 1(e) — solution

  1. Procedure header (and end) and output of highest and lowest include appropriate messages
  2. Calls Pop() until there are no items left in stack (return value = –999 // TopOfStack = -1) and
  3. Finds and outputs highest value from returned values
  4. Finds and outputs lowest value from returned values

Mark points

  • Procedure header (and end) and output of highest and lowest include appropriate messages
  • Calls Pop() until there are no items left in stack (return value = –999 // TopOfStack = -1) and
  • Finds and outputs highest value from returned values
  • Finds and outputs lowest value from returned values

Part 1(e) — solution

  1. Highest = Pop()
  2. Lowest = Highest
  3. Dim ReturnValue As Integer = Highest
  4. Highest = ReturnValue
  5. Lowest = ReturnValue
  6. ReturnValue = Pop()
  7. Highest = Pop()
  8. Lowest = Highest
  9. ReturnValue = Lowest
  10. while(ReturnValue != -999):
  11. Highest = ReturnValue
  12. Lowest = ReturnValue
  13. ReturnValue = Pop()

Visual Basic (VB.NET)

Sub FindValues()
                    Dim Highest, Lowest As Integer
                    Highest = Pop()
                    Lowest = Highest
                    Dim ReturnValue As Integer = Highest
                    While ReturnValue <> -999
                        If ReturnValue > Highest Then
                           Highest = ReturnValue
                        End If
                        If ReturnValue < Lowest Then
                           Lowest = ReturnValue
                        End If
                        ReturnValue = Pop()
                    End While
                    Console.WriteLine("The highest value is " & Highest & " and the lowest value is " &
                Lowest)
                End Sub

Python

def FindValues():
                     Highest = Pop()
                     Lowest = Highest
                     ReturnValue = Lowest
                     while(ReturnValue != -999):
                         if ReturnValue > Highest:
                             Highest = ReturnValue
                         if ReturnValue < Lowest:
                             Lowest = ReturnValue
                         ReturnValue = Pop()
                     print("The highest value is", Highest, "and the lowest value is", Lowest)

 University Press & Assessment 2025                       Page 13 of 36

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

Mark points

  • Highest = Pop()
  • Lowest = Highest
  • Dim ReturnValue As Integer = Highest
  • Highest = ReturnValue
  • Lowest = ReturnValue
  • ReturnValue = Pop()
  • Highest = Pop()
  • Lowest = Highest
  • ReturnValue = Lowest
  • while(ReturnValue != -999):
  • Highest = ReturnValue
  • Lowest = ReturnValue
  • ReturnValue = Pop()

Part 1(f)(i) — solution

1 mark for calling FindValues() 1 Example program code VB.NET FindValues() Python FindValues()

Visual Basic (VB.NET)

FindValues()

Python

FindValues()

Mark points

  • Include the ideas shown in the solution above.

Part 1(f)(ii) — solution

1 mark for a screenshot of output showing 1 Stack full output once Lowest value output in an appropriate message Highest value output in an appropriate message Lowest and Highest must be 0–1000 inclusive University Press & Assessment 2025 Page 14 of 36 9618/41 Cambridge International AS & A Level – Mark Scheme October/November 2025

Mark points

  • Include the ideas shown in the solution above.

Question 2

Paper page 4 for Q2
Original paper page 4

Part 2(a)(i) — solution

  1. Class header (and end)
  2. Declaration of 2 private attributes with correct data types
  3. Constructor header (and end) within class with 2 parameters …
  4. … assigning parameters to attributes

Visual Basic (VB.NET)

Class Train
                    Private TrainIDNumber As String
                    Private Route As Integer

                    Sub New(pNumber, pRoute)
                        TrainIDNumber = pNumber
                        Route = pRoute
                    End Sub
                End Class

Python

class Train():
                     def __init__(self, pNumber, pRoute):
                         self.__TrainIDNumber = pNumber #string
                         self.__Route = pRoute #integer

 University Press & Assessment 2025                       Page 15 of 36

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

Mark points

  • Class header (and end)
  • Declaration of 2 private attributes with correct data types
  • Constructor header (and end) within class with 2 parameters …
  • … assigning parameters to attributes

Part 2(a)(ii) — solution

  1. One get method header (and end) with no parameter …
  2. … returning correct attribute
  3. Second correct get method

Visual Basic (VB.NET)

Function GetTrainIDNumber()
                    Return TrainIDNumber
                End Function

                Function GetRoute()
                    Return Route
                End Function

Python

def GetTrainIDNumber(self):
                     return self.__TrainIDNumber

                def GetRoute(self):
                    return self.__Route

 University Press & Assessment 2025                       Page 16 of 36

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

Mark points

  • One get method header (and end) with no parameter …
  • … returning correct attribute
  • Second correct get method

Part 2(b) — solution

  1. One instance of train with correct arguments and stored in a variable/structure
  2. Remaining three instances correct

Visual Basic (VB.NET)

Dim FirstTrain As Train = New Train("12ADV", 134)
                Dim SecondTrain As Train = New Train("33ART", 20)
                Dim ThirdTrain As Train = New Train("9FKF", 3)
                Dim FourthTrain As Train = New Train("21VBC", 24)

Python

FirstTrain = Train("12ADV",134)
                SecondTrain = Train("33ART",20)
                ThirdTrain = Train("9FKF",3)
                FourthTrain = Train("21VBC",24)

 University Press & Assessment 2025                       Page 17 of 36

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

Mark points

  • One instance of train with correct arguments and stored in a variable/structure
  • Remaining three instances correct

Part 2(c)(i) — solution

  1. Class header (and end) with four private attributes with appropriate data types
  2. Constructor header (and end) within class taking 2 parameters …
  3. … assigning parameters to attributes, initialising NumberTrains to 0, initialising Trains to an empty array

Visual Basic (VB.NET)

Class Station
                    Private StationID As String
                    Private NumberPlatforms As Integer
                    Private Trains(9) As Train
                    Private NumberTrains As Integer

                    Sub New(pID, pNumberOfPlatforms)
                        StationID = pID
                        NumberPlatforms = pNumberOfPlatforms
                        NumberTrains = 0
                    End Sub
                End Class

 University Press & Assessment 2025                       Page 18 of 36

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

Mark points

  • Class header (and end) with four private attributes with appropriate data types
  • Constructor header (and end) within class taking 2 parameters …
  • … assigning parameters to attributes, initialising NumberTrains to 0, initialising Trains to an empty array

Part 2(c)(i) — solution

  1. self.__StationID = pID #string
  2. self.__NumberPlatforms = pNumberOfPlatforms #integer
  3. self.__Trains = [] #train 10 elements
  4. self.__NumberTrains = 0 #integer

Python

class Station():
                     def __init__(self, pID, pNumberOfPlatforms):
                         self.__StationID = pID #string
                         self.__NumberPlatforms = pNumberOfPlatforms #integer
                         self.__Trains = [] #train 10 elements
                         self.__NumberTrains = 0 #integer

 University Press & Assessment 2025                       Page 19 of 36

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

Mark points

  • self.__StationID = pID #string
  • self.__NumberPlatforms = pNumberOfPlatforms #integer
  • self.__Trains = [] #train 10 elements
  • self.__NumberTrains = 0 #integer

Part 2(c)(ii) — solution

  1. Method header (and close) taking one Train parameter
  2. Checking if all platforms are full and returning FALSE
  3. (Otherwise) Storing parameter in array Trains …
  4. … incrementing NumberTrains and returning True

Visual Basic (VB.NET)

Function AddTrain(NewTrain)
                    If NumberTrains >= NumberPlatforms Then
                        Return False
                    End If
                    Trains(NumberTrains) = NewTrain
                    NumberTrains = NumberTrains + 1
                    Return True
                End Function

Python

def AddTrain(self, NewTrain):
                     if self.__NumberTrains >= self.__NumberPlatforms:
                         return False
                     else:
                         self.__Trains.append(NewTrain)
                         self.__NumberTrains += 1
                         return True
 University Press & Assessment 2025                       Page 20 of 36

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

Mark points

  • Method header (and close) taking one Train parameter
  • Checking if all platforms are full and returning FALSE
  • (Otherwise) Storing parameter in array Trains …
  • … incrementing NumberTrains and returning True

Part 2(c)(iii) — solution

  1. Method header (and close) and returning a string in all cases
  2. Checking if no trains and returning "There are no trains"
  3. (Otherwise) Looping through each train in the station …
  4. … accessing train ID number and route number using get methods
  5. … creating a string with ID number and route number for each train
  6. … returning correctly formatted string

Visual Basic (VB.NET)

Function GetTrains()
                    If NumberTrains = 0 Then
                        Return "There are no trains"
                    End If
                    Dim OutputLine As String = "The trains at station " & StationID & " are:" & vbNewLine
                    For x = 0 To NumberTrains - 1
                       OutputLine = OutputLine & Trains(x). GetTrainIDNumber() & " on route number " &
                Trains(x).GetRoute() & vbNewLine
                    Next
                    Return OutputLine
                End Function

 University Press & Assessment 2025                       Page 21 of 36

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

Mark points

  • Method header (and close) and returning a string in all cases
  • Checking if no trains and returning "There are no trains"
  • (Otherwise) Looping through each train in the station …
  • … accessing train ID number and route number using get methods
  • … creating a string with ID number and route number for each train
  • … returning correctly formatted string

Part 2(c)(iii) — solution

  1. if self.__NumberTrains == 0:
  2. OutputLine = "The trains at station " + self.__StationID + " are: \n"
  3. OutputLine = OutputLine + self.__Trains[x]. GetTrainIDNumber() + " on route number

Python

def GetTrains(self):
                     if self.__NumberTrains == 0:
                         return "There are no trains"
                     OutputLine = "The trains at station " + self.__StationID + " are: \n"
                     for x in range(self.__NumberTrains):
                         OutputLine = OutputLine + self.__Trains[x]. GetTrainIDNumber() + " on route number
                " + str(self.__Trains[x].GetRoute()) + "\n"
                     return OutputLine

Mark points

  • if self.__NumberTrains == 0:
  • OutputLine = "The trains at station " + self.__StationID + " are: \n"
  • OutputLine = OutputLine + self.__Trains[x]. GetTrainIDNumber() + " on route number

Part 2(d)(i) — solution

  1. One instance of Station created with correct arguments and stored
  2. Second correct instance and stored

Visual Basic (VB.NET)

Dim SouthStation As Station = New Station("STH", 2)
                Dim NorthStation As Station = New Station("NTH", 1)

Python

SouthStation = Station("STH",2)
                NorthStation = Station("NTH",1)

 University Press & Assessment 2025                       Page 22 of 36

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

Mark points

  • One instance of Station created with correct arguments and stored
  • Second correct instance and stored

Part 2(d)(ii) — solution

  1. Calling AddTrain for 3 correct trains for station STH once
  2. Calling AddTrain for 1 correct train for station NTH once
  3. Outputting "Station is full" if any return value is FALSE
  4. Calling GetTrains() for both stations and outputting return values

Visual Basic (VB.NET)

Dim ReturnValue As Boolean = SouthStation.AddTrain(FirstTrain)
                If ReturnValue = False Then
                    Console.WriteLine("Station is full")
                End If
                ReturnValue = SouthStation.AddTrain(SecondTrain)
                If ReturnValue = False Then
 University Press & Assessment 2025                       Page 23 of 36

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

Mark points

  • Calling AddTrain for 3 correct trains for station STH once
  • Calling AddTrain for 1 correct train for station NTH once
  • Outputting "Station is full" if any return value is FALSE
  • Calling GetTrains() for both stations and outputting return values

Part 2(d)(ii) — solution

  1. ReturnValue = SouthStation.AddTrain(ThirdTrain)
  2. If ReturnValue = False Then
  3. ReturnValue = NorthStation.AddTrain(FourthTrain)
  4. If ReturnValue = False Then
  5. ReturnValue = SouthStation.AddTrain(FirstTrain)
  6. if ReturnValue == False:
  7. ReturnValue = SouthStation.AddTrain(SecondTrain)
  8. if ReturnValue == False:
  9. ReturnValue = SouthStation.AddTrain(ThirdTrain)
  10. if ReturnValue == False:
  11. ReturnValue = NorthStation.AddTrain(FourthTrain)
  12. if ReturnValue == False:

Python

ReturnValue = SouthStation.AddTrain(FirstTrain)
                if ReturnValue == False:
                     print("Station is full")

                ReturnValue = SouthStation.AddTrain(SecondTrain)
                if ReturnValue == False:
                    print("Station is full")

                ReturnValue = SouthStation.AddTrain(ThirdTrain)
                if ReturnValue == False:
                    print("Station is full")

                ReturnValue = NorthStation.AddTrain(FourthTrain)
                if ReturnValue == False:
                    print("Station is full")

                print(SouthStation.GetTrains())
                print(NorthStation.GetTrains())

 University Press & Assessment 2025                       Page 24 of 36

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

Mark points

  • ReturnValue = SouthStation.AddTrain(ThirdTrain)
  • If ReturnValue = False Then
  • ReturnValue = NorthStation.AddTrain(FourthTrain)
  • If ReturnValue = False Then
  • ReturnValue = SouthStation.AddTrain(FirstTrain)
  • if ReturnValue == False:
  • ReturnValue = SouthStation.AddTrain(SecondTrain)
  • if ReturnValue == False:
  • ReturnValue = SouthStation.AddTrain(ThirdTrain)
  • if ReturnValue == False:
  • ReturnValue = NorthStation.AddTrain(FourthTrain)
  • if ReturnValue == False:

Part 2(d)(iii) — solution

  1. One output of "Station is full"
  2. Output of correct data for both stations (in correct format)

Mark points

  • One output of "Station is full"
  • Output of correct data for both stations (in correct format)

Question 3

Paper page 9 for Q3
Original paper page 9

Part 3(a) — solution

  1. Class header (and end) and constructor header (and end) in class
  2. Constructor takes two parameters and stores each in attributes

Visual Basic (VB.NET)

Class Record
                    Dim Key As Integer
                    Dim Data As String
                    Sub New(pKey, pData)
                        Key = pKey
                        Data = pData
                    End Sub
                End Class

Python

class Record:
                     def __init__(self, pKey, pData):
                         self.Key = pKey #integer
                         self.Data = pData #string

 University Press & Assessment 2025                       Page 26 of 36

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

Mark points

  • Class header (and end) and constructor header (and end) in class
  • Constructor takes two parameters and stores each in attributes

Part 3(b) — solution

  1. 2D array of 100  10 elements of type Record
  2. Procedure InitialiseHashTable() header (and end) and initialises each element in the 2D array to an empty/null

Visual Basic (VB.NET)

Dim HashTable(99, 9) As Record
                Sub InitialiseHashTable()
                    Dim EmptyRecord As Record = New Record(-1, "")
                    For X = 0 To 99
                        For Y = 0 To 9
                            HashTable(X, Y) = EmptyRecord
                        Next
                    Next
                End Sub

Python

HashTable = []
                def InitialiseHashTable():
                     global HashTable
                     HashTable = [[Record(-1,"")]*10 for i in range(100)]

 University Press & Assessment 2025                       Page 27 of 36

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

Mark points

  • 2D array of 100  10 elements of type Record
  • Procedure InitialiseHashTable() header (and end) and initialises each element in the 2D array to an empty/null

Part 3(c) — solution

  1. Function header (and end) taking one parameter and returning calculated hash
  2. …. hash calculated correctly from parameter

Visual Basic (VB.NET)

Function Hash(Key)
                    Return Key Mod 100
                End Function

Python

def Hash(Key):
                     return Key % 100

 University Press & Assessment 2025                       Page 28 of 36

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

Mark points

  • Function header (and end) taking one parameter and returning calculated hash
  • …. hash calculated correctly from parameter

Part 3(d) — solution

  1. Procedure header (and end) taking one Record parameter
  2. Calling Hash() using key from parameter and storing/using return value
  3. Accessing HashTable[return][0] and storing parameter if no collision … … if collision: iterating through 2 nd

Visual Basic (VB.NET)

Function InsertData(RecordData)
                   Dim HashValue As Integer = Hash(RecordData.Key)

                    For X = 0 To 9
                        If HashTable(HashValue, X).Key = -1 Then
                            HashTable(HashValue, X) = RecordData
                            X= 10
                        End If
                    Next X
                End Function

 University Press & Assessment 2025                       Page 29 of 36

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

Mark points

  • Procedure header (and end) taking one Record parameter
  • Calling Hash() using key from parameter and storing/using return value
  • Accessing HashTable[return][0] and storing parameter if no collision … … if collision: iterating through 2 nd

Part 3(d) — solution

  1. HashValue = Hash(RecordData.Key)
  2. if HashTable[HashValue][X].Key == -1:
  3. HashTable[HashValue][X] = RecordData

Python

def InsertData(RecordData):
                     global HashTable

                      HashValue = Hash(RecordData.Key)

                      for X in range(0, 10):
                          if HashTable[HashValue][X].Key == -1:
                              HashTable[HashValue][X] = RecordData

 University Press & Assessment 2025                       Page 30 of 36

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

Mark points

  • HashValue = Hash(RecordData.Key)
  • if HashTable[HashValue][X].Key == -1:
  • HashTable[HashValue][X] = RecordData

Part 3(e) — solution

  1. Procedure header (and end), opening file and closing file (in appropriate place)
  2. Iterating through each line in file // reading each line in from file
  3. Splitting each line read in by comma …
  4. … creating Record object with each key and data as arguments …
  5. … calling InsertData() with each object
  6. Try, catch with appropriate output and all file access within try

Mark points

  • Procedure header (and end), opening file and closing file (in appropriate place)
  • Iterating through each line in file // reading each line in from file
  • Splitting each line read in by comma …
  • … creating Record object with each key and data as arguments …
  • … calling InsertData() with each object
  • Try, catch with appropriate output and all file access within try

Part 3(e) — solution

  1. Line = FileReader.ReadLine()
  2. Data = Split(Line, ",")
  3. TheRecord = New Record(Integer.Parse(Data(0)), Data(1))
  4. File = open("HashTableData.txt")
  5. Data = Line.strip()
  6. Data = Line.split(",")

Visual Basic (VB.NET)

Sub ReadData()
                    Dim Line As String
                    Dim Data(3) As String
                    Dim TheRecord As Record

                      Dim FileReader As New System.IO.StreamReader("HashTableData.txt")
                      While Not FileReader.EndOfStream
                          Line = FileReader.ReadLine()
                          Data = Split(Line, ",")
                          TheRecord = New Record(Integer.Parse(Data(0)), Data(1))
                          InsertData(TheRecord)
                      End While
                      FileReader.Close()

                End Sub

Python

def ReadData():
                     global HashTable
                     File = open("HashTableData.txt")
                     for Line in File:
                         Data = Line.strip()
                         Data = Line.split(",")
                         InsertData(Record(int(Data[0]), Data[1]))
                     File.close()

 University Press & Assessment 2025                       Page 32 of 36

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

Mark points

  • Line = FileReader.ReadLine()
  • Data = Split(Line, ",")
  • TheRecord = New Record(Integer.Parse(Data(0)), Data(1))
  • File = open("HashTableData.txt")
  • Data = Line.strip()
  • Data = Line.split(",")

Part 3(f) — solution

  1. Function header (and end) taking one parameter and returning string in all cases
  2. Calling Hash() with parameter and storing/using return value
  3. Iterating through 2 nd dimension at HashTable[return value] and comparison to parameter …
  4. … returning data if found/equal
  5. … returning "Not found" if not found by the end of the dimension

Visual Basic (VB.NET)

Function GetRecord(Key)
                    Dim HashValue As Integer = Hash(Key)

                    For X = 0 To 9
                        If HashTable(HashValue, X).Key = Key Then
                            Return HashTable(HashValue, X).Data
                        End If
                    Next X
                    Return "Not found"
                End Function

 University Press & Assessment 2025                       Page 33 of 36

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

Mark points

  • Function header (and end) taking one parameter and returning string in all cases
  • Calling Hash() with parameter and storing/using return value
  • Iterating through 2 nd dimension at HashTable[return value] and comparison to parameter …
  • … returning data if found/equal
  • … returning "Not found" if not found by the end of the dimension

Part 3(f) — solution

  1. HashValue = Hash(Key)
  2. if HashTable[HashValue][X].Key == Key:

Python

def GetRecord(Key):
                     global HashTable

                      HashValue = Hash(Key)
                      for X in range(0, 10):
                          if HashTable[HashValue][X].Key == Key:
                              return HashTable[HashValue][X].Data

                      return "Not found"

 University Press & Assessment 2025                       Page 34 of 36

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

Mark points

  • HashValue = Hash(Key)
  • if HashTable[HashValue][X].Key == Key:

Part 3(g)(i) — solution

  1. Calling InitialiseHashTable() then ReadData()
  2. Taking five (integer) inputs
  3. Calling GetRecord() with each input and outputting return value

Visual Basic (VB.NET)

Sub Main(args As String())
                    InitialiseHashTable()
                    ReadData()

                    For X = 0 To 5
                        Console.WriteLine("Enter key field")
                        Console.WriteLine(GetRecord(Console.ReadLine()))
                    Next
                End Sub

 University Press & Assessment 2025                       Page 35 of 36

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

Mark points

  • Calling InitialiseHashTable() then ReadData()
  • Taking five (integer) inputs
  • Calling GetRecord() with each input and outputting return value

Part 3(g)(i) — solution

  1. Key = int(input("Enter key field "))

Python

InitialiseHashTable()
                ReadData()

                for x in range(5):
                    Key = int(input("Enter key field "))
                    print(GetRecord(Key))

Mark points

  • Key = int(input("Enter key field "))

Part 3(g)(ii) — solution

  1. Input of the 4 integers and matching word output
  2. Input of 39 and output of Not found

Mark points

  • Input of the 4 integers and matching word output
  • Input of 39 and output of Not found