Data structures: OCR A‑Level Computer Science questions
Every OCR A-Level Computer Science exam question on 1.4.2 Data structures, 2021–2025, with its mark scheme and examiner’s report.
Find questions593
Calculations
Q3(a)
The whole paper ↗![June 2025 Paper 2, question 3(a): Show the contents of the stack and its pointer value after the data items "t" and "s" are inserted in the order given. 5 4 3 2 1 0 pointer = [2]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h44602-jun25-03-a-qp.webp)
Q3(b)
The whole paper ↗
Q3(c)
The whole paper ↗
Q3(d)
The whole paper ↗
Q7(a)
The whole paper ↗![June 2025 Paper 2, question 7(a): Add the following data items in the given order to the binary search tree above. 5 30 53 57 90 [3]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h44602-jun25-07-a-qp.webp)
Q7(b)
The whole paper ↗
Q8(a)
The whole paper ↗![June 2025 Paper 2, question 8(a): Describe the features of a linked list data structure. [3]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h44602-jun25-08-a-qp.webp)
Q8(c)(ii)
The whole paper ↗
Q8(d)
The whole paper ↗
Q8(e)
The whole paper ↗
Q8(g)
The whole paper ↗
Q6(b)(i)
The whole paper ↗![June 2025 AS Paper 1, question 6(b)(i): An alternative data structure Beth could have used is a list. Describe two differences between a list and an array. 1 2 [4]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h04601-jun25-06-bi-qp.webp)
Q2(a)
The whole paper ↗![June 2025 AS Paper 2, question 2(a): One characteristic of the array is that it has 2 dimensions. Identify two other characteristics of the given array. 1 2 [2]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h04602-jun25-02-a-qp.webp)
Q6(a)
The whole paper ↗![June 2025 AS Paper 2, question 6(a): Describe one difference between a queue and a stack. [2]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h04602-jun25-06-a-qp.webp)
Q6(b)(i)
The whole paper ↗![June 2025 AS Paper 2, question 6(b)(i): State the purpose of topPointer in the stack. [1]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h04602-jun25-06-bi-qp.webp)
Q6(b)(ii)
The whole paper ↗![June 2025 AS Paper 2, question 6(b)(ii): Describe the steps that will be followed to remove an item from the stack. [3]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h04602-jun25-06-bii-qp.webp)
Q6(b)(iii)
The whole paper ↗
Q8(a)
The whole paper ↗![June 2024 Paper 1, question 8(a): Write a line of program code or pseudocode to declare the array towns. [2]](https://pub-e8a9dbab8e2a4d089f52b2a45e0d0b50.r2.dev/bank/h44601-jun24-08-a-qp.webp)
Q8(b)(i)
The whole paper ↗
Q8(b)(ii)
The whole paper ↗
All 81 questions on Data structures, as a list
- June 2025, Paper 2, Q3(a) (2 marks): Show the contents of the stack and its pointer value after the data items "t" and "s" are inserted in the order given. 5 4 3 2 1 0 pointer = [2]
- June 2025, Paper 2, Q3(b) (4 marks): The stack is stored using a 0-based 1-dimensional array called theStack with 20 elements. The function push() stores its parameter into the next space in the st
- June 2025, Paper 2, Q3(c) (6 marks): A pointer value of -1 indicates that the stack is empty. The function pop() returns the next element in the stack. If the stack is empty it returns "false". The
- June 2025, Paper 2, Q3(d) (5 marks): A program is designed to reverse a set of data using the stack. The main program takes 10 characters separately as input from the user and uses the function pus
- June 2025, Paper 2, Q7(a) (3 marks): Add the following data items in the given order to the binary search tree above. 5 30 53 57 90 [3]
- June 2025, Paper 2, Q7(b) (2 marks): A balanced binary search tree has data consistently at each level, for example: An unbalanced binary search tree is uneven, for example: Describe the drawback o
- June 2025, Paper 2, Q8(a) (3 marks): Describe the features of a linked list data structure. [3]
- June 2025, Paper 2, Q8(c)(ii) (5 marks): 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 outputLi
- June 2025, Paper 2, Q8(d) (5 marks): 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
- June 2025, Paper 2, Q8(e) (5 marks): 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 l
- June 2025, Paper 2, Q8(g) (12 marks): A linked list data structure is designed using object-oriented programming. The design includes two classes called node and linkedList. (g)* This program uses c
- June 2025, AS Paper 1, Q6(b)(i) (4 marks): An alternative data structure Beth could have used is a list. Describe two differences between a list and an array. 1 2 [4]
- June 2025, AS Paper 2, Q2(a) (2 marks): One characteristic of the array is that it has 2 dimensions. Identify two other characteristics of the given array. 1 2 [2]
- June 2025, AS Paper 2, Q6(a) (2 marks): Describe one difference between a queue and a stack. [2]
- June 2025, AS Paper 2, Q6(b)(i) (1 mark): State the purpose of topPointer in the stack. [1]
- June 2025, AS Paper 2, Q6(b)(ii) (3 marks): Describe the steps that will be followed to remove an item from the stack. [3]
- June 2025, AS Paper 2, Q6(b)(iii) (3 marks): Complete the function to insert a new data item onto the stack. function push(dataItem) if topPointer ……………………………………………… 7 then return false else topPointer = …
- June 2024, Paper 1, Q8(a) (2 marks): Write a line of program code or pseudocode to declare the array towns. [2]
- June 2024, Paper 1, Q8(b)(i) (4 marks): In the 2-dimensional array towns: • the first column contains a pointer to the left side • the second column contains the data • the third column contains a poi
- June 2024, Paper 1, Q8(b)(ii) (4 marks): Four more towns are added to the binary search tree shown in Fig. 8 in this order: Mallow Cavan Tuam Wexford Complete this binary search tree by adding the new
- June 2024, Paper 2, Q3(b) (4 marks): State four ways that a graph data structure is different from a tree data structure. 1 2 3 4 [4]
- June 2024, Paper 2, Q4(a) (2 marks): State the purpose of headPointer and tailPointer in the queue shown in Fig. 4. headPointer tailPointer [2]
- June 2024, Paper 2, Q4(b) (2 marks): enqueue will add data to the queue. dequeue will remove data from the queue. Show the contents of the queue and the position of both pointers after the followin
- June 2024, Paper 2, Q4(c) (2 marks): The queue is used to store ID numbers of jobs that a program needs to process. Some jobs will be given a priority which means they need to be processed first. E
- June 2024, Paper 2, Q5(a) (4 marks): The function pop() returns the next item from the stack and updates the appropriate pointers. Describe the steps in the function pop(). [4]
- June 2024, Paper 2, Q5(b) (4 marks): The function push() inserts its parameter called dataValue onto the stack and updates the appropriate pointers. Complete the function push() using pseudocode or
- June 2024, Paper 2, Q5(c) (4 marks): Write an algorithm, using pseudocode or program code, to call the function push() with the value 15 and output a message saying "Added" if the value was success
- June 2024, Paper 2, Q7(a) (2 marks): The data about each task needs to be stored. This will store the ID number, data value and order number for a task. Explain why a record data structure is suita
- June 2024, Paper 2, Q7(b)(i) (2 marks): Give two characteristics of a binary search tree. 1 2 [2]
- June 2024, Paper 2, Q7(b)(ii) (1 mark): Give an advantage of storing the tasks in a binary search tree instead of a 1-dimensional array. [1]
- June 2024, Paper 2, Q7(b)(iv) (3 marks): The tasks currently stored in the binary search tree are shown here. When a new task is inserted with the same order number as a pre-existing task, it is classe
- June 2024, Paper 2, Q9(a) (3 marks): The road is designed to be a 1-dimensional array with the identifier road. Explain why an array is a suitable data structure to represent the road. [3]
- June 2024, AS Paper 2, Q2(a) (2 marks): Identify one similarity and one difference between a stack and a queue. Similarity Difference [2]
- June 2024, AS Paper 2, Q2(b)(iv) (3 marks): The function enqueue can be called by the main program. Explain why the function enqueue returns true or false values, and how this can be used by the main prog
- June 2024, AS Paper 2, Q2(b)(v) (3 marks): The pseudocode function, dequeue, removes and returns the first item in the queue. If the queue is empty, the function returns the string "EMPTY". 01 function d
- June 2024, AS Paper 2, Q2(b)(vi) (3 marks): The programmer has corrected all of the errors in the function dequeue. The main program repeatedly calls the function dequeue until all of the elements in the
- June 2023, Paper 1, Q2(a) (5 marks): Complete the pseudocode here to implement Sundip’s algorithm. do value = input("Enter a value") if ………………………………………………………………………………… then num = numbers.pop() prin
- June 2023, Paper 1, Q2(b)(i) (3 marks): Complete the diagram to show the state of the stack after each value is entered into the algorithm. The letters will complete an action stated in Fig. 2. The st
- June 2023, Paper 1, Q2(b)(ii) (3 marks): 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 actio
- June 2023, Paper 1, Q2(b)(iii) (3 marks): Explain what problem this input data will cause and why the problem occurs. [3]
- June 2023, Paper 1, Q2(c)(i) (2 marks): Describe one difference between a stack and a queue. [2]
- June 2023, Paper 1, Q2(c)(ii) (2 marks): Describe one difference between an array and a list. [2]
- June 2023, Paper 1, Q2(c)(iii) (1 mark): State how a tuple is different to a list. [1]
- June 2023, Paper 1, Q2(c)(iv) (3 marks): Describe how the second item in a linked list would be accessed using pointer values. [3]
- June 2023, Paper 2, Q1(a)(i) (2 marks): Give two characteristics of a tree data structure. 1 2 [2]
- June 2023, Paper 2, Q1(a)(ii) (4 marks): The following data is entered into a binary search tree. 22 13 5 36 55 14 8 Draw the binary search tree when the given data is entered in the order given. [4]
- June 2023, Paper 2, Q1(a)(iii) (2 marks): Describe how a leaf node is deleted from a binary search tree. [2]
- June 2023, Paper 2, Q1(a)(iv) (4 marks): Describe how a binary search tree can be searched for a value. [4]
- June 2023, Paper 2, Q3(a) (2 marks): State the purpose of headPointer and freeListPointer in the linked list shown in Fig. 3. headPointer freeListPointer [2]
- June 2023, Paper 2, Q3(b) (1 mark): State the meaning of the pointers with the value NULL in the linked list shown in Fig. 3. [1]
- June 2023, Paper 2, Q3(c) (2 marks): 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]
- June 2023, Paper 2, Q3(d) (4 marks): A new item needs to be added to the linked list. Describe how a new item is added to a linked list. [4]
- June 2023, Paper 2, Q3(e) (5 marks): 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. T
- June 2023, AS Paper 1, Q2(a)(i) (1 mark): Tick one box that describes how a queue operates. Last In First Out First In First Out [1]
- June 2023, AS Paper 1, Q2(a)(ii) (2 marks): The figure below shows a queue data structure that contains a list of names. Alex is at the front of the queue. Alex Kofi Ben Sundip Tom The operations that can
- June 2023, AS Paper 1, Q2(b)(i) (4 marks): Complete the pseudocode function for the pop() operation. function pop() if top == …………………………… then return –1 else item = items[……………………………] top = top – …………………
- June 2023, AS Paper 1, Q2(b)(ii) (7 marks): A function called reverse uses a stack called theStack to reverse data that is passed in as a parameter called name. For example, the name “Jack” would be retur
- June 2023, AS Paper 2, Q6(b) (4 marks): Describe how an array can be used to store and access data in a stack data structure. [4]
- June 2022, Paper 2, Q2(a) (1 mark): Identify the root node in the binary tree shown in Fig. 2. [1]
- June 2022, Paper 2, Q2(b) (2 marks): Identify two leaf nodes in the binary tree shown in Fig. 2. 1 2 [2]
- June 2022, Paper 2, Q2(c) (4 marks): Four more students are added to the binary search tree shown in Fig. 2 in this order: 1420 2050 2780 2600 Complete the binary search tree here by adding the new
- June 2022, Paper 2, Q3(a) (1 mark): State why the integer values are stored in an array instead of separate variables. [1]
- June 2022, Paper 2, Q5(a)(i) (1 mark): State one way a directed graph is different to an undirected graph. [1]
- June 2022, Paper 2, Q5(a)(ii) (1 mark): State one way a graph data structure is different to a tree data structure. [1]
- June 2022, Paper 2, Q6(c) (2 marks): The cards are held in the 2D array cards. The first index stores the card number and the second index stores the suit, both as strings. Write a pseudocode state
- June 2022, Paper 2, Q8(a)(i) (2 marks): The function pop() removes an item from the stack. The function push() adds an item to the stack that is passed in as a parameter. Show the contents of the stac
- June 2022, Paper 2, Q8(a)(ii) (1 mark): State the purpose of pointerValue. [1]
- June 2022, Paper 2, Q8(b)(i) (5 marks): The method pop() returns the next value in the stack, or –1 if the stack is empty. Complete the pseudocode method pop(). public function pop() if pointerValue =
- June 2022, Paper 2, Q8(b)(ii) (6 marks): The method push() accepts an integer as a parameter and adds it to the top of the stack unless the stack is already full. If the push is successful the method r
- June 2022, Paper 2, Q8(b)(iv) (4 marks): The main program needs to: • take numbers as input from the user • push them onto the stack mathsStack until the stack is full • output an appropriate message i
- June 2022, Paper 2, Q8(b)(v) (8 marks): The main program also needs to: • remove one item from the stack at a time and add this to a total • output the total every time an item is removed • stop remov
- June 2022, Paper 2, Q8(c)(i) (3 marks): Describe how an array can be used to implement a queue data structure. [3]
- June 2022, AS Paper 1, Q1(e)(ii) (2 marks): Interrupt Service Handlers make use of a stack data structure. Describe how a stack is used when handling interrupts. [2]
- November 2021, Paper 1, Q7(a)(i) (1 mark): State the name of the type of data structure described above. [1]
- November 2021, Paper 1, Q7(a)(ii) (4 marks): 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 struc
- November 2021, Paper 1, Q7(b)(i) (4 marks): Complete the tree diagram above to show where Martyn, Louise, Alex and Anna would be added to this binary search tree. [4]
- November 2021, Paper 1, Q7(b)(ii) (3 marks): Describe the process of using the binary search tree above to search for the name “Zoe”. [3]
- November 2021, Paper 1, Q7(b)(iii) (2 marks): Compare the efficiency of a binary search tree to a linked list when searching for data. [2]
- November 2021, Paper 1, Q7(b)(iv) (2 marks): Compare the efficiency of a binary search tree to a hash table when searching for data. [2]
- November 2021, Paper 2, Q7(a) (4 marks): The program needs two pointers to access and manipulate the data in the queue. State the purpose of the two pointers and give an appropriate identifier for each
- November 2021, Paper 2, Q7(b) (5 marks): Lucas wants a procedure, enqueue(), that will add the parameter it is passed to the queue. Describe the steps the procedure enqueue() will follow when adding ne
Questions, mark schemes and examiner’s reports are © OCR, from their published past papers. Plumi isn’t affiliated with any exam board. Want whole papers? Full past papers.
Rather write your answers by hand on iPad? Plumi marks them against the same mark schemes.