A Level Computer Science 9618 Paper 42, Oct/Nov 2025

Question paper and mark scheme75 marks3 questions

Solve it on ExamPal

Practise

Untimed. Write on the paper and check as you go.

Start

Exam

Timed, with a clock you set, like sitting the real paper.

Start

Opens full screen.

Opening the question paper

Read as textThe questions and the mark scheme as plain text. Easier to read on a phone.

Question paper

9618/42 · Oct/Nov 2025

Download PDF
1

A program stores data about birds using Object-Oriented Programming (OOP). The class Bird stores the data about the birds: Bird DistancePerHour : Real | stores the number of kilometres per hour (km/h) the bird can fly (between 0.0 and 100.0 inclusive) Species : String | stores the species of the bird, for example Pigeon XPosition : Real | stores the current horizontal position of the bird YPosition : Real | stores the current vertical position of the bird Constructor() | initialises Species and DistancePerHour to the parameter values; initialises XPosition and YPosition to 500.0 GetPosition() | returns a string message that contains the horizontal and vertical position of the bird GetSpecies() | returns the species of the bird Move() | takes a direction and number of minutes flying (between 0 and 500 inclusive) as parameters and updates the appropriate horizontal or vertical position

a(i)

Write program code to declare the class Bird and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program as Question1_N25. Copy and paste the program code into part 1(a)(i) in the evidence document.

[4]
a(ii)

The method GetSpecies() returns the species of the bird. Write program code for GetSpecies() Save your program. Copy and paste the program code into part 1(a)(ii) in the evidence document.

[2]
a(iii)

The method GetPosition() returns a string of the bird’s data in the format: "X = " & <XPosition> & " Y = " & <YPosition> An example string for a bird is: X = 500.0 Y = 250.0 Write program code for GetPosition() Save your program. Copy and paste the program code into part 1(a)(iii) in the evidence document.

[3]
a(iv)

If the bird is travelling north, the vertical position increases. If the bird is travelling south, the vertical position decreases. If the bird is travelling east, the horizontal position increases. If the bird is travelling west, the horizontal position decreases. The method Move(): • takes the direction of travel as a parameter in the form ‘N’ for north, ‘S’ for south, ‘E’ for east or ‘W’ for west • takes the number of minutes that the bird has been flying (to the nearest minute) as a parameter • calculates the distance travelled by the bird using the formula: distance travelled = (distance per hour/60) * minutes flying • updates the vertical or horizontal position using the distance calculated. You do not need to validate the parameters. Write program code for Move() Save your program. Copy and paste the program code into part 1(a)(iv) in the evidence document.

[5]
b

The main program creates two instances of Bird The first bird is the species ‘Cockatiel’ and flies 71.0km/h. The second bird is the species ‘Macaw’ and flies 56.0km/h. Write program code to declare and initialise the two birds. Save your program. Copy and paste the program code into part 1(b) in the evidence document.

[3]
c(i)

The main program needs to: • output a message that includes the species and current X position and Y position for each bird • prompt the user to select one of the birds to move and take this as an input • prompt the user to enter the direction the bird has been travelling and take this as an input • prompt the user to enter the time to the nearest minute that the bird has been travelling and take this as an input • call the appropriate method to update the chosen bird’s position • output an update on the bird’s new position. Each input needs to repeat until valid data is entered. All outputs must be meaningful. Write program code to amend the main program. Save your program. Copy and paste the program code into part 1(c)(i) in the evidence document.

[8]
c(ii)

Test your program four times to meet these criteria: Test 1: The Cockatiel travels north for 60 minutes. Test 2: The Macaw travels south for 30 minutes. Test 3: The Cockatiel travels west for 30 minutes. Test 4: The Macaw travels east for 60 minutes. Take a screenshot of the output(s). Save your program. Copy and paste the screenshot(s) into part 1(c)(ii) in the evidence document.

[3]
2

A program stores 20 unique random integers between 0 and 100 (inclusive) in a 1D array that is local to the main program.

a

Write program code to declare the array local to the main program and store 20 unique random numbers between 0 and 100 (inclusive) in the array. Save your program as Question2_N25. Copy and paste the program code into part 2(a) in the evidence document.

[3]
b

The procedure PrintArray() takes an integer array as a parameter. The procedure outputs the array contents on a single line with a space between each integer. Write the program code for PrintArray() Save your program. Copy and paste the program code into part 2(b) in the evidence document.

[3]
c

The function BubbleSort(): • takes an integer array as a parameter • sorts the data into ascending order using a bubble sort • returns the sorted array. The function needs to work for an array of any length. Do not use an inbuilt sorting method. Write program code for BubbleSort() Save your program. Copy and paste the program code into part 2(c) in the evidence document.

[5]
d(i)

The main program: • outputs the contents of the array using PrintArray() • sorts the array using BubbleSort() • outputs "Sorted" • outputs the contents of the sorted array using PrintArray() Write program code for the main program. Save your program. Copy and paste the program code into part 2(d)(i) in the evidence document.

[3]
d(ii)

Test your program. Take a screenshot of the output(s). Save your program. Copy and paste the screenshot(s) into part 2(d)(ii) in the evidence document.

[1]
e

The recursive function RecursiveBinarySearch() takes four parameters: • an integer array • the lower bound of the array • the upper bound of the array • the value to find in the array. The recursive function performs a binary search to find the index of the value in the array. The function returns the index of the value if it is found. The function returns –1 if the value is not found. Write program code for RecursiveBinarySearch() Save your program. Copy and paste the program code into part 2(e) in the evidence document.

[6]
f(i)

The main program: • prompts the user to enter an integer • takes the integer as input • calls RecursiveBinarySearch() with the sorted array, appropriate lower bound, appropriate upper bound and the user’s input as parameters • outputs "Not found" if the input is not within the array • outputs "Found at position" and the index if the input is within the array. Write program code to amend the main program. Save your program. Copy and paste the program code into part 2(f)(i) in the evidence document.

[3]
f(ii)

Test your program three times with each of the inputs described: Test 1: the smallest number in the array Test 2: the largest number in the array Test 3: a number not in the array Take a screenshot of each output. Save your program. Copy and paste the screenshot(s) into part 2(f)(ii) in the evidence document.

[2]
3

A program stores integers in ascending order in an ordered binary tree. The tree is implemented as a 2D array. Each node is stored with three values: • a pointer to the left node • the data • a pointer to the right node. All null values are stored as –1 The binary tree can store up to 50 nodes. Nodes cannot be deleted from the binary tree.

a

The binary tree is stored as a global array with the identifier TreeArray. The left pointer, the data and the right pointer of each node are initialised to –1 The global variable RootPointer stores the index of the root node in the tree, initialised to –1 The global variable FreeNode stores the index of the next free node in the array, initialised to 0 Write program code to declare and initialise TreeArray, RootPointer and FreeNode Save your program as Question3_N25. Copy and paste the program code into part 3(a) in the evidence document.

[3]
b

The procedure AddNode(): • takes an integer to store in the binary tree as a parameter • stores the parameter in the next free node in the array • finds the position to store the data in the tree by following the appropriate pointers • updates the pointer of the new node’s parent node. The procedure outputs "The tree is full" if the parameter cannot be stored because the tree is full. Write program code for AddNode() Save your program. Copy and paste the program code into part 3(b) in the evidence document.

[7]
c

The text file TreeData.txt stores 50 integers. Each integer is on a new line in the file. The main program reads each integer from the file and stores each integer in the binary tree in the order they are read. Write program code for the main program. Save your program. Copy and paste the program code into part 3(c) in the evidence document.

[4]
d

The procedure WriteAllToFile() stores the content of TreeArray in a new text file with the filename Tree.txt. The file Tree.txt is not provided. Each node in TreeArray is stored on one line with a comma separating each value. For example, the current contents of TreeArray are: Index 0 1 2 0 –1 20 1 1 –1 30 –1 … 49 -1 -1 -1 After writing TreeArray to the text file, Tree.txt will contain: –1,20,1 –1,30,–1 … -1,-1,-1 Write program code for WriteAllToFile() Include exception handling when writing to the file. Save your program. Copy and paste the program code into part 3(d) in the evidence document.

[5]
e(i)

Amend the main program to call WriteAllToFile() Save your program. Copy and paste the program code into part 3(e)(i) in the evidence document.

[1]
e(ii)

Test your program. Take a screenshot that shows all of the content stored in the file Tree.txt In this screenshot you need to make sure the filename is visible. Save your program. Copy and paste the screenshot(s) into part 3(e)(ii) in the evidence document.

[1]

Mark scheme

9618/42 · Oct/Nov 2025

Download PDF

1a(i) · 4 marks

  • 1 mark

    Class header (and end)

  • 1 mark

    4 private attributes with correct data types

  • 1 mark

    Constructor header (and end) taking 2 parameters within class …

  • 1 mark

    … within constructor assigning parameters to Species and DistancePerHour and assigning 500.0 to XPosition and YPosition

1a(ii) · 2 marks

  • 1 mark

    Get method header (and end) with no parameter ….

  • 1 mark

    … returning Species

1a(iii) · 3 marks

  • 1 mark

    Get method header (and end) with no parameter, returning a value

  • 1 mark

    Creating correct string using attributes …

  • 1 mark

    … returning this string

1a(iv) · 5 marks

  • 1 mark

    Method header (and end) taking direction and minutes flying as parameters

  • 1 mark

    Calculation of distance using minutes flying parameter and attribute DistancePerHour

  • 1 mark

    Selection based on direction parameter …

  • 1 mark

    … north adding to YPosition and south subtracting from YPosition

  • 1 mark

    … east adding to XPosition and west subtracting from XPosition

1b · 3 marks

  • 1 mark

    Cockatiel 71.0 instance of Bird created …

  • 1 mark

    Macaw 56.0 instance of Bird created …

  • 1 mark

    … both stored in variables/structures

1c(i) · 8 marks

  • 1 mark

    Output species, X and Y position for both Bird objects in appropriate messages(s)

  • 1 mark

    Prompt and input of bird choice, time and direction …

  • 1 mark

    … validating all three inputs …

  • 1 mark

    … looping until all three are valid

  • 1 mark

    Calling Move() for chosen bird …

  • 1 mark

    … with only input direction and input time as arguments

  • 1 mark

    Outputting new position for the bird moved

  • 1 mark

    Using get methods throughout where appropriate

1c(ii) · 3 marks

  • 1 mark

    screenshot showing inputs for one test with correct output

  • 1 mark

    screenshot showing inputs for a second test with correct output

  • 1 mark

    screenshot showing inputs for a third and fourth test with correct output

2a · 3 marks

  • 1 mark

    Creation of 1D array …

  • 1 mark

    … with 20 generated random integers between 0 and 100 (inclusive) …

  • 1 mark

    … all 20 random integers are unique

2b · 3 marks

  • 1 mark

    Procedure header (and close) taking (array) as parameter

  • 1 mark

    Outputting array contents once …

  • 1 mark

    … on one line with a space between each integer

2c · 5 marks

  • 1 mark

    Function header (and end) taking (array) parameter and returning a sorted array after sorting

  • 1 mark

    Outer loop …

  • 1 mark

    … inner loop ...

  • 1 mark

    … comparing elements and swapping into ascending order

  • 1 mark

    Sort must work for array of any length i.e. loops for length of parameter array

2d(i) · 3 marks

  • 1 mark

    Calling PrintArray() with array as argument

  • 1 mark

    Calling BubbleSort() with array as argument and storing/using return value

  • 1 mark

    Outputting "Sorted" and calling PrintArray() with (returned) array as argument

2d(ii) · 1 mark

  • 1 mark

    Output shows unsorted array of 20 integers between 0 and 100 inclusive before sorting, “Sorted” output, array of the same integers sorting into ascending order.

2e · 6 marks

  • 1 mark

    Function header (and end) taking four parameters and recursive function written

  • 1 mark

    Calculating middle value

  • 1 mark

    Comparing middle value to data parameter and returning index if equal

  • 1 mark

    If middle is greater than, recursive call with middle –1 for upper

  • 1 mark

    If middle is less than, recursive call with middle + 1 for lower

  • 1 mark

    Checking if not found and returning –1

2f(i) · 3 marks

  • 1 mark

    Prompt and input of integer

  • 1 mark

    Call of RecursiveBinarySearch(SortedArray, 0, 19, input) and storing/using return value

  • 1 mark

    Output of "Not found" if –1 returned and output "Found at position" with index returned if found

2f(ii) · 2 marks

  • 1 mark

    screenshot showing smallest number in array input and found message with index 0 and screenshot showing highest number in array input and found message with index 19

  • 1 mark

    screenshot showing a number not in the array input and an output of "Not found"

3a · 3 marks

  • 1 mark

    (global) TreeArray declared as a 2D array with 50  3 elements …

  • 1 mark

    … all initialised to –1

  • 1 mark

    (global) RootPointer initialised to –1 and FreeNode initialised to 0

3b · 7 marks

  • 1 mark

    Procedure header (and end) taking one (integer) parameter and storing parameter in array in index TreeArray[FreeNode][1]

  • 1 mark

    Checking if tree is full (FreeNode = 50) and outputting "The tree is full"

  • 1 mark

    Checking if tree is empty (RootPointer = -1 // FreeNode = 0) and if so, storing 0 in RootPointer

  • 1 mark

    (if not empty) Comparing parameter to data at index TreeArray[RootPointer][1] …

  • 1 mark

    … if less than, accessing left node …

  • 1 mark

    … if greater than, accessing right node …

  • 1 mark

    … until location found …

  • 1 mark

    … updating parent node's appropriate pointer

  • 1 mark

    Incrementing FreeNode

3c · 4 marks

  • 1 mark

    Opening the file to read and closing the file in an appropriate place

  • 1 mark

    Looping 50 times/through file/through each line/until EOF …

  • 1 mark

    … reading in each line …

  • 1 mark

    … calling AddNode() with each value read in

  • 1 mark

    Exception handling try, catch, except with appropriate message

3d · 5 marks

  • 1 mark

    Procedure header (and end) and with exception handling for writing to file: try, catch, except with appropriate message

  • 1 mark

    Opening the file (Tree.txt) to write and closing the file in appropriate place

  • 1 mark

    Looping through each element in array …

  • 1 mark

    … creating correct string

  • 1 mark

    … writing each string to the file

3e(i) · 1 mark

  • 1 mark

    1 mark for calling WriteAllToFile()

3e(ii) · 1 mark

  • 1 mark

    1 mark for a screenshot that shows correct data stored, each node on a new line (in correct format). The screenshot must include the filename.

Questions

  1. 1
    Question 128 marks
    Mark scheme ›
  2. 2
    Question 226 marks
    Mark scheme ›
  3. 3
    Question 321 marks
    Mark scheme ›

More 9618 papers

Other papers from Oct/Nov 2025

Solve it on ExamPalStart