Skip to main content
A-LevelComputer ScienceFurther programming9618/43 · May/June 2025 · Q329 Marks

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 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

  1. (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.[4]
  2. (a)(ii)Write program code for the two get methods.[3]
  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()[2]
  4. (b)(i)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.[2]
  5. (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()[4]
  6. (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()[3]
  7. (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()[6]
  8. (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.[3]
  9. (c)(ii)Test your program. Take a screenshot of the output(s).[2]

Mark scheme

Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.

  1. [1 mark each] (a)(i) • Class Node header (and end) • TheData declared as Integer, NextNode declared as Node • Constructor header (and end) taking (min) 1 parameter ... • ...storing parameter to TheData within constructor and storing null value to NextNode within constructor
  2. [1 mark each] (a)(ii) • 1 get method header (and close) taking no parameters ... • ...returning correct value (without overwriting) • 2nd correct get method
  3. [1 mark each] (a)(iii) • SetNextNode() method header (and close) taking 1 parameter (of type Node) • ...storing parameter in NextNode
  4. [1 mark each] (b)(i) • Class LinkedList header (and close) and constructor header with no parameter (and close) ... • ...declaring HeadNode as type Node and storing null value in constructor
  5. [1 mark each] (b)(ii) • InsertNode() method header (and close) taking one (integer) parameter • Creating new instance of Node with the parameter as the argument • Calling SetNextNode() for new node with HeadNode as parameter • Replacing HeadNode with new node
  6. [1 mark each] (b)(iii) • Traverse() method header (and close) with no parameter and returns created string • Starts at head node and follows nodes using GetNextNode() until no nodes left ... • ...concatenates the data from each node and formats correctly
  7. [1 mark each to max 6] (b)(iv) • RemoveNode() method header (and close) taking (integer) parameter and returning Boolean in all cases • Checking if head node is null and returning FALSE • Checking if head node equals parameter and returning TRUE if true ... • ...and updating HeadNode to HeadNode.GetNextNode() • Following nodes comparing data from each node to parameter ... • ...if found updating next node and returning TRUE • ...if end of list returning FALSE
  8. [1 mark each] (c)(i) • Creating new LinkedList object • Calling InsertNode() five times with correct data in correct order • Calling RemoveNode(30) and calling Traverse() and store/output the return value, before RemoveNode() and after Full marks can be awarded to students who may have stored and/or outputted the return value from the function call.
  9. [1 mark each] (c)(ii) • Output of linked list with 50 40 30 20 10 • Output of 2nd linked list with 50 40 20 10 e.g. 50 40 30 20 10 50 40 20 10

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 29 marks.
Source
A-Level Computer Science, May/June 2025 Paper 4 Variant 3, question 3.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep