A Level Computer Science 9618 Paper 43, May/June 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/43 · May/June 2025

Download PDF
1

A program reads data from a text file and stores it in a queue. The linear queue Queue is stored as a 1D array of up to 50 elements. The queue has the following pointers: • HeadPointer – this stores the index of the first element in the queue, initialised to –1 • TailPointer – this stores the index of the last element in the queue, initialised to –1

a

Queue is a global array of 50 integers with all elements initialised to –1 in the main program. The two pointers are declared as global variables and initialised to –1 Write program code to declare and initialise Queue, HeadPointer and TailPointer Save your program as Question1_J25. Copy and paste the program code into part 1(a) in the evidence document.

[3]
b

The function Enqueue(): • takes an integer parameter to store in the next position in the queue • returns FALSE if the queue is full and the parameter cannot be stored in the queue • returns TRUE if the parameter is stored in the queue • updates the pointers where appropriate. Write program code for Enqueue() Save your program. Copy and paste the program code into part 1(b) in the evidence document.

[6]
c

The function Dequeue(): • returns the next item in the queue, if the queue is not empty • returns –1 if the queue is empty • updates the pointers where appropriate. Write program code for Dequeue() Save your program. Copy and paste the program code into part 1(c) in the evidence document.

[5]
d

The text file QueueData.txt stores positive integers. Each integer is on a new line in the file. The procedure CreateQueue(): • opens the file QueueData.txt • reads in each line from the text file and uses Enqueue() to insert each line into the queue • outputs "Queue full" if any item cannot be inserted into the queue • uses exception handling when opening and reading from the text file. The procedure needs to work for a file that contains an unknown number of lines. Write program code for CreateQueue() Save your program. Copy and paste the program code into part 1(d) in the evidence document.

[6]
e(i)

The main program needs extending to call CreateQueue(). The main program then adds together all of the integers stored in the queue, using Dequeue() to access each integer. The total is then output. Write program code to extend the main program. Save your program. Copy and paste the program code into part 1(e)(i) in the evidence document.

[5]
e(ii)

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

[1]
2

A program sorts the data in the 1D array DataArray and searches DataArray for specific values. DataArray stores 14 integer values and is declared local to the main program.

a

Write program code to create DataArray and initialise it with the following data values in the order they are written: 0 3 4 56 67 44 43 32 31 345 45 6 54 1 Save your program as Question2_J25. Copy and paste the program code into part 2(a) in the evidence document.

[1]
b

The function InsertionSort() takes an array of integers as a parameter. The function sorts the data in the array into ascending numerical order using an insertion sort. The function returns the sorted array. Write program code for InsertionSort() You must not use any inbuilt sorting functions for your programming language. Save your program. Copy and paste the program code into part 2(b) in the evidence document.

[5]
c

The procedure OutputArray() takes an array of integers as a parameter. The procedure outputs each element in the array from the first element to the last element. The output is on one line with a space between each number. An example output is: "0 3 4 56 67 44 43 32 31 345 45 6 54 1" Write program code for OutputArray() Save your program. Copy and paste the program code into part 2(c) in the evidence document.

[2]
d(i)

The main program needs extending to: • output the content of the unsorted array using OutputArray() • sort the array using InsertionSort() • output the content of the sorted array using OutputArray() Write program code to extend the main program. Save your program. Copy and paste the program code into part 2(d)(i) in the evidence document.

[2]
d(ii)

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

[1]
e

The function Search() performs a binary search to find ItemToFind in DataArray The function takes two parameters: • DataArray, an array of integers • ItemToFind, an integer to find in DataArray The function returns: • the index of ItemToFind if it is in DataArray • –1 if ItemToFind is not in DataArray Write program code for Search() You must not use any inbuilt searching functions for your programming language. Save your program. Copy and paste the program code into part 2(e) in the evidence document.

[6]
f(i)

The main program needs extending to call Search() with the sorted array four times: • the first time to find the index of the integer 0 • the second time to find the index of the integer 345 • the third time to find the index of the integer 67 • the fourth time to find the index of the integer 2 If the integer is found in the array, output an appropriate message that includes the index. If the integer is not found, output that it was not found. Write program code to extend the main program. Save your program. Copy and paste the program code into part 2(f)(i) in the evidence document.

[2]
f(ii)

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

[1]
3

A program stores data in a linked list that is designed using Object‑Oriented Programming (OOP). The class Node stores data about the nodes. Node TheData : Integer stores the integer data NextNode : Node stores the next node in the linked list Constructor() initialises TheData to its parameter value, initialises NextNode to a null value GetData() returns TheData GetNextNode() returns NextNode SetNextNode() takes an object of type Node as a parameter and stores it in NextNode

a(i)

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

[4]
a(ii)

Write program code for the two get methods. Save your program. Copy and paste the program code into part 3(a)(ii) in the evidence document.

[3]
a(iii)

The method SetNextNode() takes an object of type Node as a parameter. The method stores the parameter in the attribute NextNode Write program code for SetNextNode() Save your program. Copy and paste the program code into part 3(a)(iii) in the evidence document.

[2]
b(i)

The class LinkedList stores the linked list. LinkedList HeadNode : Node stores the first node in the linked list Constructor() initialises HeadNode to a null value InsertNode() creates a new node using its integer parameter. Sets this node as the new head node and updates NextNode RemoveNode() finds the first node that contains its integer parameter and removes this node from the linked list Traverse() concatenates and returns the integer data in each node in the linked list Write program code to declare the class LinkedList and its constructor. Do not declare the other methods. Use your programming language appropriate constructor. If you are writing in Python, include attribute declarations using comments. Save your program. Copy and paste the program code into part 3(b)(i) in the evidence document.

[2]
b(ii)

The method InsertNode(): • takes an integer as a parameter • creates a new node with the parameter as the integer data • uses the new node’s method SetNextNode() to store the current HeadNode as the next node • replaces HeadNode with the current node. Write program code for InsertNode() Save your program. Copy and paste the program code into part 3(b)(ii) in the evidence document.

[4]
b(iii)

The method Traverse() concatenates the integer data from the nodes in the linked list, starting with the node stored in HeadNode. The method returns the final string with each integer data separated with a space. Write program code for Traverse() Save your program. Copy and paste the program code into part 3(b)(iii) in the evidence document.

[3]
b(iv)

The method RemoveNode() takes an integer parameter to search for and remove from the linked list. The method first checks if the linked list is empty. If the linked list is empty the method returns FALSE If the linked list is not empty, the integer data in HeadNode is compared to the parameter. If it matches the parameter, HeadNode is changed to store the next node. If the parameter does not match, the nodes are followed until either: • the node with matching integer data is found. This node is removed, the appropriate nodes updated and TRUE returned or • none of the nodes contain matching integer data to the parameter. No nodes are removed and FALSE is returned. Write program code for RemoveNode() Save your program. Copy and paste the program code into part 3(b)(iv) in the evidence document.

[6]
c(i)

The main program creates a new LinkedList object and uses the appropriate method to insert five nodes with the following integer data values in the order given: 10 20 30 40 50 The main program then: • calls Traverse() • removes the node containing the integer data 30 using RemoveNode() • calls Traverse() Write program code for the main program. Save your program. Copy and paste the program code into part 3(c)(i) in the evidence document.

[3]
c(ii)

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

[2]

Mark scheme

9618/43 · May/June 2025

Download PDF

1a · 3 marks

  • 1 mark

    (Global) Queue array with 50 integer elements …

  • 1 mark

    … all initialised to –1

  • 1 mark

    (Global) HeadPointer and TailPointer initialised with –1

1b · 6 marks

  • 1 mark

    Function Enqueue() header (and end) taking one (integer) parameter

  • 1 mark

    Checking if Queue is full …

  • 1 mark

    …returning FALSE if full and TRUE if not full

  • 1 mark

    (Otherwise) storing data item at TailPointer + 1 (check incrementing)

  • 1 mark

    Incrementing TailPointer

  • 1 mark

    Checking if this is the first element and incrementing/storing 0 in HeadPointer

1c · 5 marks

  • 1 mark

    Function Dequeue() header (and close) and returning appropriate value in all cases.

  • 1 mark

    Checking if queue is empty …

  • 1 mark

    … and returning –1 if empty

  • 1 mark

    Accessing and returning element at Queue[HeadPointer] (before HeadPointer is incremented)

  • 1 mark

    Incrementing HeadPointer

1d · 6 marks

  • 1 mark

    CreateQueue() header (and end) and opening the file to read and closing file in appropriate place

  • 1 mark

    Looping until end of file

  • 1 mark

    Reading in each/all lines (and converting to integer and removing new line)

  • 1 mark

    … calling Enqueue() once with each value …

  • 1 mark

    … checking return value and outputting "Queue full" if full (can output once or many times)

  • 1 mark

    Exception try, catch with appropriate output. All file access within try

1e(i) · 5 marks

  • 1 mark

    Calling CreateQueue()

  • 1 mark

    Calling Dequeue() and storing/using return value …

  • 1 mark

    … repeatedly until return value is –1

  • 1 mark

    … adding together all return values to create a total within the loop …

  • 1 mark

    … outputting the total

1e(ii) · 1 mark

  • 1 mark

    1 mark for screenshot showing 3059

2a · 1 mark

  • 1 mark

    1 mark for array declared with data values: 0 3 4 56 67 44 43 32 31 345 45 6 54 1

2b · 5 marks

  • 1 mark

    InsertionSort() header (and close) taking array as a parameter and returning (attempt at) sorted array

  • 1 mark

    Looping through/for each element

  • 1 mark

    Extracting element and comparing to sorted list …

  • 1 mark

    … moving elements in sorted list

  • 1 mark

    … and inserting element in correct position (ascending order)

2c · 2 marks

  • 1 mark

    OutputArray() header (and close) taking an array parameter and outputting the array contents …

  • 1 mark

    … in correct format

2d(i) · 2 marks

  • 1 mark

    Calling InsertionSort() with array parameter and storing/using return array

  • 1 mark

    … calling OutputArray() with array parameter before and after InsertionSort()

2d(ii) · 1 mark

  • 1 mark

    1 mark for output showing unsorted then sorted array

2e · 6 marks

  • 1 mark

    Search() header (and close) taking array and integer as parameters

  • 1 mark

    Looping/recursive calls until no elements left/Low<=High and returning –1 if not found

  • 1 mark

    … calculating middle index and accessing this value

  • 1 mark

    … comparison of array at middle value to integer parameter

  • 1 mark

    … if they are equal return mid

  • 1 mark

    … if array[mid] < parameter update low to middle + 1, if array[mid] > parameter update high to middle – 1 // recursive call with updated low and updated high

2f(i) · 2 marks

  • 1 mark

    Calling Search() with all four sets of values 0 345 67 2

  • 1 mark

    … outputting 'not found' or index in appropriate message each time

2f(ii) · 1 mark

  • 1 mark

    1 mark for output showing locations for first 3 and not found for 4th

3a(i) · 4 marks

  • 1 mark

    Class Node header (and end)

  • 1 mark

    TheData declared as Integer, NextNode declared as Node

  • 1 mark

    Constructor header (and end) taking (min) 1 parameter …

  • 1 mark

    … storing parameter to TheData within constructor and storing null value to NextNode within constructor

3a(ii) · 3 marks

  • 1 mark

    1 get method header (and close) taking no parameters …

  • 1 mark

    … returning correct value (without overwriting)

  • 1 mark

    2nd correct get method

3a(iii) · 2 marks

  • 1 mark

    SetNextNode() method header (and close) taking 1 parameter (of type Node) …

  • 1 mark

    … storing parameter in NextNode

3b(i) · 2 marks

  • 1 mark

    Class LinkedList header (and close) and constructor header with no parameter (and close) …

  • 1 mark

    … declaring HeadNode as type Node and storing null value in constructor

3b(ii) · 4 marks

  • 1 mark

    InsertNode()method header (and close) taking one (integer) parameter

  • 1 mark

    Creating new instance of Node with the parameter as the argument

  • 1 mark

    Calling SetNextNode() for new node with HeadNode as parameter

  • 1 mark

    Replacing HeadNode with new node

3b(iii) · 3 marks

  • 1 mark

    Traverse() method header (and close) with no parameter and returns created string

  • 1 mark

    Starts at head node and follows nodes using GetNextNode() until no nodes left …

  • 1 mark

    … concatenates the data from each node and formats correctly

3b(iv) · 6 marks

  • 1 mark

    RemoveNode() method header (and close) taking (integer) parameter and returning Boolean in all cases

  • 1 mark

    Checking if head node is null and returning FALSE

  • 1 mark

    Checking if head node equals parameter and returning TRUE if true …

  • 1 mark

    … and updating HeadNode to HeadNode.GetNextNode()

  • 1 mark

    Following nodes comparing data from each node to parameter …

  • 1 mark

    ... if found updating next node and returning TRUE

  • 1 mark

    … if end of list returning FALSE

3c(i) · 3 marks

  • 1 mark

    Creating new LinkedList object

  • 1 mark

    Calling InsertNode() five times with correct data in correct order

  • 1 mark

    Calling RemoveNode(30) and calling Traverse() and store/output the return value, before RemoveNode() and after

3c(ii) · 2 marks

  • 1 mark

    Output of linked list with 50 40 30 20 10

  • 1 mark

    Output of 2nd linked list with 50 40 20 10

Questions

  1. 1
    Question 126 marks
    Mark scheme ›
  2. 2
    Question 220 marks
    Mark scheme ›
  3. 3
    Question 329 marks
    Mark scheme ›

More 9618 papers

Other papers from May/June 2025

Solve it on ExamPalStart