BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. A Level
  3. Computer Science
  4. OCR
  5. Linked lists

OCR A Level Computer Science

Topic questions Data structures Linked lists

Linked lists

9 questions · 231 marks · about 4 hours

Linked lists questions

OCR H446 Linked lists 9 questions

Algorithms and programming June 2025, Question 8 40 marks

Also involves Arrays

A linked list data structure is designed using object-oriented programming.

The design includes two classes called node and linkedList.

(a)

Describe the features of a linked list data structure.

[3]
Reveal mark scheme Mark scheme for question 8(a)
(b)

The class design for node is shown here.

Figure for question 8

new() is the constructor method. The constructor method takes a parameter and assigns this to the value attribute.

(b)(i)

The method getNextNode() returns the attribute nextNode.

Write the method getNextNode() using pseudocode or program code.

[2]
Reveal mark scheme Mark scheme for question 8(b)(i)
(b)(ii)

The method setValue() takes an integer as a parameter and assigns this to the attribute value

Write the method setValue() using pseudocode or program code.

[3]
Reveal mark scheme Mark scheme for question 8(b)(ii)
(c)

The class design for linkedList is shown here.

Figure for question 8

new() is the constructor method. The constructor initialises the attribute headNode to a null value.

(c)(i)

Write the constructor method using pseudocode or program code.

[2]
Reveal mark scheme Mark scheme for question 8(c)(i)
(c)(ii)

The class design for node and linkedList are shown again here for your reference.

Figure for question 8

The method getValue() will return the value of a node. The method getNextNode() will return the next node to be accessed in the linked list.

The method outputList() traverses the linked list starting at the node headNode. The method joins the data in each node and returns it.

Complete the method outputList() using pseudocode or program code.

Figure for question 8
[5]
Reveal mark scheme Mark scheme for question 8(c)(ii)
(d)

The method insertNode() will insert a new node into the linked list.

The method accepts an integer as a parameter, creates a new node with that data and inserts it into the linked list, e.g. insertNode(8) creates a node object with the data 8 and adds it to the linked list.

The program needs to store the following data items in the linked list in the order they are given: 10 25 39

The program then needs to output all of the data in the list using the appropriate method.

Write an algorithm using pseudocode or program code to:

• create a new linkedList object with the identifier createList

• insert each of the data items into the linked list (10, 25, 39)

• output the content of the linked list.

[5]
Reveal mark scheme Mark scheme for question 8(d)
(e)

A new method is needed to remove a node from the linked list. The method needs to take the data to remove as a parameter and then find this data in the linked list before removing the node.

Describe the steps that this method will need to follow and the decisions that need to be made in the method to remove the correct node.

[5]
Reveal mark scheme Mark scheme for question 8(e)
(f)

The program developer made use of computational methods when designing the object-oriented programming solution. One computational method is divide-and-conquer.

Identify three other computational methods that the program developer could have used.

[3]
Reveal mark scheme Mark scheme for question 8(f)
(g)

* This program uses classes and objects to create a linked list.

An alternative method is creating a 2-dimensional array. In this design the first index stores the data and the second element stores the index of the next data item. Array elements not currently used are also linked together to form a chain of empty values to identify where the next data item can be inserted.

Compare the two different methods of creating a linked list that have been described.

You should include the following in your answer:

• the features of both methods including the reusability of program components

• benefits and drawbacks of both methods in this program

• a conclusion evaluating the efficiency of both methods when designing a program that needs

a linked list.

[12]
Reveal mark scheme Mark scheme for question 8(g)

Computer systems June 2023, Question 2 22 marks

Sundip writes an algorithm to carry out addition and subtraction. The algorithm will use an initially empty stack with the identifier numbers and will take input from the user.

The action the algorithm takes depends on the value input by the user. These actions are listed in

Figure for question 2
(a)

Complete the pseudocode here to implement Sundip’s algorithm.

Figure for question 2
[5]
Reveal mark scheme Mark scheme for question 2(a)
(b)(i)
Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(i)
(b)(ii)

Complete the following table to give the output from this algorithm when the following set of inputs are entered by the user. The letters will complete an action stated in Fig. 2

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(ii)
(b)(iii)

If the user enters 4 2 S A E, the algorithm will not work correctly.

Explain what problem this input data will cause and why the problem occurs.

[3]
Reveal mark scheme Mark scheme for question 2(b)(iii)
(c)

A stack is one data structure that is available for Sundip to use. She could also use a queue, list, linked list, array or tuple.

(c)(i)

Describe one difference between a stack and a queue.

[2]
Reveal mark scheme Mark scheme for question 2(c)(i)
(c)(ii)

Describe one difference between an array and a list.

[2]
Reveal mark scheme Mark scheme for question 2(c)(ii)
(c)(iii)

State how a tuple is different to a list.

[1]
Reveal mark scheme Mark scheme for question 2(c)(iii)
(c)(iv)

Describe how the second item in a linked list would be accessed using pointer values.

[3]
Reveal mark scheme Mark scheme for question 2(c)(iv)

Algorithms and programming June 2023, Question 3 14 marks

A program stores data in a linked list.

The current contents of the linked list are shown in Fig. 3, along with the linked list pointers.

Figure for question 3
(a)

State the purpose of headPointer and freeListPointer in the linked list shown in Fig. 3.

[2]
Reveal mark scheme Mark scheme for question 3(a)
(b)

State the meaning of the pointers with the value NULL in the linked list shown in Fig. 3.

[1]
Reveal mark scheme Mark scheme for question 3(b)
(c)

A procedure outputs the data in the linked list shown in Fig. 3 from the first item in the list, to the last item.

Give the output from the procedure.

[2]
Reveal mark scheme Mark scheme for question 3(c)
(d)

A new item needs to be added to the linked list.

Describe how a new item is added to a linked list.

[4]
Reveal mark scheme Mark scheme for question 3(d)
(e)

The function findNode will search the linked list and return either the position of the node that contains the data item, or-1 if the data item is not found.

The data held in a node at location x can be accessed with linkedList[x].data. The pointer of the node at location x can be accessed with linkedList[x].pointer.

Figure for question 3

Complete the function, using pseudocode or program code.

Figure for question 3
[5]
Reveal mark scheme Mark scheme for question 3(e)

Computer systems November 2021, Question 7 24 marks

Also involves Algorithm efficiency and Big O notation

A business uses an array with the identifier wNames to store workers’ names. A variable with the identifier top is used to store the index of the last element to be added to the array, which is also the element which will next be removed.

Figure for question 7
(a)(i)

State the name of the type of data structure described above.

[1]
Reveal mark scheme Mark scheme for question 7(a)(i)
(a)(ii)

Using pseudocode, write an algorithm that allows the user to enter a name which is then pushed onto the data structure above, checking first that the data structure is not full.

[4]
Reveal mark scheme Mark scheme for question 7(a)(ii)
(b)

The same workers’ names are stored in a binary search tree which is ordered alphabetically.

Kirstie is set as the root node, with Martyn, Louise, Alex and Anna added one by one.

Figure for question 7
Reveal mark scheme Mark scheme for question 7(b)
(b)(i)

Complete the tree diagram above to show where Martyn, Louise, Alex and Anna would

be added to this binary search tree.

[4]
(b)(ii)

Describe the process of using the binary search tree above to search for the name “Zoe”.

[3]
(b)(iii)

Compare the efficiency of a binary search tree to a linked list when searching for data.

[2]
(b)(iv)

Compare the efficiency of a binary search tree to a hash table when searching for data.

[2]
(c)

An object oriented system is implemented to organise further information about each worker’s attendance. Classes, objects, methods and attributes are used in this system.

(c)(i)

State the meaning of each of the following terms:

Object........

Method........

Attribute........

[3]
Reveal mark scheme Mark scheme for question 7(c)(i)
(c)(ii)

Each worker has a name and an attendance figure which can be between 0 and 100.

Write a definition for a fully encapsulated customer class, providing both get and set methods for all attributes. You do not have to write code for the constructor method.

[5]
Reveal mark scheme Mark scheme for question 7(c)(ii)

Algorithms and programming November 2020, Question 6 40 marks

Barney is writing a program to store data in a linked list. He is writing the initial program for a maximum of 10 data items.

Each node in the linked list has a data value and a pointer (to the next item).

A null pointer is stored with the value –1.

(a)
Figure for question 6
(a)(i)

Describe the purpose of freeListPointer.

[2]
Reveal mark scheme Mark scheme for question 6(a)(i)
(a)(ii)

State the purpose of headPointer.

[1]
Reveal mark scheme Mark scheme for question 6(a)(ii)
(a)(iii)
Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(a)(iii)
(b)

Barney wants the nodes to be stored as objects using object-oriented programming. He designs the following class.

Figure for question 6

The constructor assigns the parameters to the attributes to create an object.

(b)(i)
Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(b)(i)
(b)(ii)

The class node, uses get methods and set methods.

Describe one difference between get methods and set methods.

[2]
Reveal mark scheme Mark scheme for question 6(b)(ii)
(c)

The function findNodePath() takes the data item to find in the linked list as a parameter and follows the pointers to find the required node.

The function returns the array indexes of all the nodes it visits and joins this to a suitable message stating whether the data was found or not found and then returns this as one string.

Describe how the function findNodePath() will search for the data item and return the required message.

[6]
Reveal mark scheme Mark scheme for question 6(c)
(d)

The procedure printLinkedList() follows the pointers to print all of the elements in the linked list.

Figure for question 6

The procedure has a number of errors.

(d)(i)

Identify the line of each error and write the corrected line.

Error 1 line number........

Error 1 correction........

Error 2 line number........

Error 2 correction........

Error 3 line number........

Error 3 correction........

[3]
Reveal mark scheme Mark scheme for question 6(d)(i)
(d)(ii)

Barney will use an Integrated Development Environment (IDE) to debug his program code.

Describe three features commonly found in IDEs that Barney could use to debug his program code.

[6]
Reveal mark scheme Mark scheme for question 6(d)(ii)
(e)

* Barney would like his linked list to be part of a base program that is saved in a library. This means that it can be reused and changed by other programs.

Discuss the benefits of using different object-oriented techniques that Barney could use to achieve this.

[12]
Reveal mark scheme Mark scheme for question 6(e)

Computer systems June 2019, Question 5 23 marks

Also involves String manipulation

A programmer is writing software for a firewall. She is writing code so that it keeps a track of websites that users are permitted to visit. The software stores the websites’ addresses along with details about who can view them and when.

The following data is also stored about each website:

• Access level needed (1-4) • If it is available all the time (true) or just lunch times and out of work hours (false).

So a website which is available to users of access level 2 and above, all the time, would have the details [2, true] stored.

A website accessible to users of access level 3 and above, only outside of work hours, would have the details [3, false] stored.

(a)

State the name of a data structure that could be used to store a single site’s details.

[1]
Reveal mark scheme Mark scheme for question 5(a)
(b)
Figure for question 5 Figure for question 5
[1]
Reveal mark scheme Mark scheme for question 5(b)
(c)
Figure for question 5 Figure for question 5
[5]
Reveal mark scheme Mark scheme for question 5(c)
(d)

A flaw with the current hash function is it tends to generate lots of collisions (addresses that compute to the same hash). Below is a diagram of part of the hash table. The address www.rnd.com with details [2, true] is being added to the hash table.

Explain how a hash table can be used to handle collisions, referring to the example below.

227
228www.ocr.org.uk : [1, true]
229
230www.ppf.nz : [2, false]
231
232www.ntf.biz : [4, true]
234
235
[4]
Reveal mark scheme Mark scheme for question 5(d)
(e)

The hash function is changed so there are no longer high numbers of collisions.

During busy periods the firewall is expected to check several addresses a second. It is anticipated that roughly 10 new addresses will be added to a whitelist (list of acceptable addresses) each day.

There is a debate as to whether a hash table (with the new hash function) is the best approach, or if the whitelist would be better stored in a linked list.

*Discuss whether a hash table or linked list is better to store acceptable websites. You should compare how each structure can be searched and has data added and come to a

recommendation as to which is better for the whitelist.

[12]
Reveal mark scheme Mark scheme for question 5(e)

Algorithms and programming June 2019, Question 2 22 marks

Also involves Trees and binary search trees

A program needs to store the names of plants that are in a garden, so they can be easily found and accessed in alphabetical order.

The data is stored in a tree structure. Part of the tree is shown.

Figure for question 2
(a)
(a)(i)

State the type of tree shown in Fig. 2.1.

[1]
Reveal mark scheme Mark scheme for question 2(a)(i)
(a)(ii)

Show the output of a breadth-first traversal of the tree shown in Fig. 2.1.

[3]
Reveal mark scheme Mark scheme for question 2(a)(ii)
(a)(iii)

Explain how backtracking is used in a depth-first (post-order) traversal. Use the tree in Fig. 2.1 in your explanation.

Figure for question 2
[4]
Reveal mark scheme Mark scheme for question 2(a)(iii)
(b)

The elements in the tree in Fig. 2.1 are read into a linked list producing an alphabetised list.

(b)(i)

Complete the following table to show the linked list for the data.

Figure for question 2
[2]
Reveal mark scheme Mark scheme for question 2(b)(i)
(b)(ii)

A new plant, Lavender, needs adding to the linked list. The linked list needs to retain its alphabetical order.

Complete the table to show the linked list after Lavender is added.

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(ii)
(b)(iii)

Hosta needs removing from the linked list.

Explain how a data item is removed from a linked list. Use the removal of Hosta in your answer.

[4]
Reveal mark scheme Mark scheme for question 2(b)(iii)
(b)(iv)

The linked list is stored as a 2D array with the identifier plantList. The index of the first element of the linked list is stored in the identifier firstElement.

All contents of the linked list need to be output in alphabetical order.

Write an algorithm to follow the pointers to output the contents of the linked list in alphabetical order.

Add comments to explain your code.

[5]
Reveal mark scheme Mark scheme for question 2(b)(iv)

Computer systems June 2017, Question 2 11 marks

A coach company offers tours of the UK.

(a)

A linked list stores the names of cities on a coach tour in the order they are visited.

Figure for question 2
(a)(i)

Describe what is meant by the term ‘linked list’.

[3]
Reveal mark scheme Mark scheme for question 2(a)(i)
(a)(ii)

The tour is amended. The new itinerary is: London, Oxford, Manchester then York. Explain how Birmingham is removed from the linked list and how York is added. You may use the diagram below to illustrate your answer.

Figure for question 2
[4]
Reveal mark scheme Mark scheme for question 2(a)(ii)
(b)

The program stores records about its customers.

Often an individual customer’s record needs to be accessed. This is done by searching using the Customer ID. Explain why a hash table is better suited than a linked list to store the customer records, particularly as the company acquires more customers.

[4]
Reveal mark scheme Mark scheme for question 2(b)

Algorithms and programming June 2017, Question 2 35 marks

Also involves Trace tables · Arrays

A programmer is developing an ordering system for a fast food restaurant. When a member of staff inputs an order, it is added to a linked list for completion by the chefs.

(a)

Explain why a linked list is being used for the ordering system.

[2]
Reveal mark scheme Mark scheme for question 2(a)
(b)
Figure for question 2
(b)(i)

Order 158 has been made, and needs adding to the end of the linked list.

Add the order, 158, to the linked list as shown in Fig. 2.1. Show the contents of the linked list in the following table.

Figure for question 2
[2]
Reveal mark scheme Mark scheme for question 2(b)(i)
(b)(ii)

Order 159 has been made. This order has a high priority and needs to be the second order in the linked list. Add the order, 159, to the original linked list as shown in Fig. 2.1. Show the contents of the linked list in the following table.

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(b)(ii)
(c)

The linked list is implemented using a 2D array, theOrders:

• Row 0 stores orderNo

• Row 1 stores next

The data now stored in theOrders is shown in Fig. 2.2.

Figure for question 2

The following algorithm is written:

Figure for question 2
(c)(i)

Outline why nodeNo does not need to be stored in the array.

[1]
Reveal mark scheme Mark scheme for question 2(c)(i)
(c)(ii)

Complete the trace table for procedure x, for the data shown in Fig. 2.2.

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(c)(ii)
(c)(iii)

Describe the purpose of procedure x.

[2]
Reveal mark scheme Mark scheme for question 2(c)(iii)
(c)(iv)

A new order, 190, is to be added to theOrders. It needs to be the third element in the list. The current contents of the array are repeated here for reference:

Figure for question 2

Describe how the new order, 190, can be added to the array, so the linked list is read in the correct order, without rearranging the array elements.

[4]
Reveal mark scheme Mark scheme for question 2(c)(iv)
(d)

The user needs to be able to search for, and find, a specific order number.

State an appropriate search algorithm that could be used, and justify your choice against an alternative Search algorithm.

Appropriate Search Algorithm........

[3]
Reveal mark scheme Mark scheme for question 2(d)
(e)

The programmer is writing the program using an IDE.

Identify three features of an IDE that the programmer would use when writing the code and describe how the features benefit the programmer.

[6]
Reveal mark scheme Mark scheme for question 2(e)
(f)

(f*) The programmer is considering using concurrent programming.

Discuss how concurrent programming can be applied to the food ordering system and the

benefits and limitations of doing so.

[9]
Reveal mark scheme Mark scheme for question 2(f)

Report a problem with a question on this page
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors