Data structures — AQA A-Level Computer Science
Data structures in AQA A-Level Computer Science provide systematic ways of organising, managing, and storing data to enable efficient access and modification. Master static vs dynamic allocations, abstract data types including stacks, queues, graphs, trees, hash tables, and dictionaries, alongside their practical implementations and algorithmic complexities.
Data structures explained
A data structure is a way of organising and storing data so that it can be accessed and modified efficiently for a particular purpose.
Read the full explanation
Being familiar with the concept means understanding that the same data can be held in different structures, and that the choice affects how easily data can be inserted, searched, sorted or retrieved. Common examples include arrays, which store items in a fixed-size sequence accessed by index; lists, which can grow and shrink; stacks, which follow last-in first-out order; queues, which follow first-in first-out order; and trees and graphs, which represent hierarchical or networked relationships. A learner should be able to recognise what kind of structure suits a given problem, such as a stack for reversing a sequence or a queue for scheduling tasks in arrival order.
Your focus
- Be familiar with the concept of data structures.
Which command word is this?
Set out the causes, reasons, or inner workings of a structure or algorithm clearly. Marks are awarded for linked technical steps, not standalone definitions.
Data structures exam tips
Topic Overview
Data structures form the foundational architecture for managing and manipulating information inside computer systems. This unit covers basic primitive types, arrays, composite records, and abstract data types (ADTs) such as stacks, queues, linked lists, trees, graphs, and hash tables.
Understanding the mechanics, memory footprints, and access patterns of these structures is essential for designing efficient algorithms in Paper 1 and Paper 2. AQA requires students to distinguish between static and dynamic allocations and to trace operations on ADTs using both dry-run tables and formal pseudo-code.
Key Concepts
- →Static vs Dynamic structures: Static structures (e.g., fixed-size arrays) have predetermined memory allocations at compile-time, while dynamic structures (e.g., linked lists, binary trees) allocate heap memory at runtime via pointers.
- →LIFO vs FIFO protocols: Stacks operate under Last-In, First-Out using push/pop with a stack pointer; queues operate under First-In, First-Out using enqueue/dequeue with front/rear pointers.
- →Non-linear ADTs: Graphs represent arbitrary pairwise relationships using adjacency matrices (dense) or adjacency lists (sparse); trees are connected, acyclic, directed/undirected graphs with unique paths between nodes.
- →Collision handling in Hash Tables: Hashing transforms keys into indices; collisions are resolved using open addressing (linear probing) or closed addressing (chaining with linked lists).
Marking Points
- States that a data structure organises data so it can be used efficiently.
- Identifies the order or access rule that distinguishes at least two structures, such as LIFO for a stack and FIFO for a queue.
- Explains that the choice of structure affects operations such as insertion, search and retrieval.
- Matches a suitable structure to a described problem.
Examiner Tips
- 💡Learn the access rule for each common structure, since multiple-choice items often test this.
- 💡When matching a structure to a problem, identify the required order of processing first.
- 💡Keep the concept separate from any single programming language's implementation.
- 💡Always check edge conditions when tracing stacks or queues: verify stack overflow (top == max_size) or stack underflow (top == -1 or 0 depending on base index) before executing operations.
- 💡When drawing binary search trees after insertions, retain the canonical BST invariant: values strictly smaller go left, values strictly greater go right.
- 💡In pseudo-code questions, clearly show pointer movements before dereferencing or updating pointers to prevent dangling references and memory leaks.
Common Mistakes
- Treats a data structure as only a variable type; correct it by explaining the organisation and access rules it provides.
- Confuses stacks and queues; correct it by stating a stack is last-in first-out and a queue is first-in first-out.
- Assumes one structure is always best; correct it by linking the choice to the operations the problem needs.
- Assuming dynamic data structures are always superior to static data structures; dynamic structures incur pointer overheads (extra memory) and slower, non-contiguous access times due to cache misses.
- Believing that an adjacency matrix is always better than an adjacency list; an adjacency matrix consumes O(V^2) memory regardless of edge count, making it wasteful for sparse graphs compared to adjacency lists.
- Thinking that deleting a node from an array automatically shrinks its allocated memory size; arrays retain their fixed block unless explicitly reallocated by a higher-level abstraction.
Revision Plan
- 1Day 1-3: Review static vs dynamic memory; implement and trace stack and linear/circular queue operations using arrays and pointers.
- 2Day 4-6: Master linked lists (singly and doubly linked); write algorithms for node insertion, traversal, and deletion.
- 3Day 7-9: Study non-linear structures: Binary Search Trees (in-order, pre-order, post-order traversals) and Graphs (adjacency matrix vs list).
- 4Day 10-12: Practise hash tables, hashing functions, load factors, linear probing, and collision handling techniques.
- 5Day 13-14: Complete timed past-paper questions from AQA Paper 1 and Paper 2 covering pointer-based pseudo-code questions.
Exam Question Types
- 📋Algorithm trace tables: Step-by-step tracing of enqueue/dequeue, push/pop, or tree traversals tracking pointer states.
- 📋Pseudo-code implementation: Writing subroutines to traverse linked lists, add items to binary trees, or check queue states.
- 📋Compare and contrast essays: Evaluating trade-offs between adjacency matrices vs lists, or static arrays vs linked lists in specific contextual scenarios.
Command Word Expectations (AQA)
Set out the causes, reasons, or inner workings of a structure or algorithm clearly. Marks are awarded for linked technical steps, not standalone definitions.
Identify both similarities and differences between two data structures (e.g., array vs linked list), linking points back to memory usage, time complexity, or access mechanics.
Follow the execution of an algorithm dry-run line-by-line, updating index pointers, memory cell values, and conditional flags in a structured trace table.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A circular queue of capacity 5 is implemented using an array Q[0..4], with variables front = 0, rear = -1, and size = 0. Trace the values of front, rear, and size after the following operations: Enqueue('A'), Enqueue('B'), Dequeue(), Enqueue('C'), Enqueue('D'), Enqueue('E'), Enqueue('F'). Explain what happens on the final operation.
- 1.Step 1: Enqueue('A'): rear = ( -1 + 1 ) MOD 5 = 0; Q[0] = 'A'; size = 1.
- 2.Step 2: Enqueue('B'): rear = ( 0 + 1 ) MOD 5 = 1; Q[1] = 'B'; size = 2.
- 3.Step 3: Dequeue(): front = ( 0 + 1 ) MOD 5 = 1; size = 1 ('A' is removed logically).
- 4.Step 4: Enqueue('C'): rear = ( 1 + 1 ) MOD 5 = 2; Q[2] = 'C'; size = 2.
- 5.Step 5: Enqueue('D'): rear = ( 2 + 1 ) MOD 5 = 3; Q[3] = 'D'; size = 3.
- 6.Step 6: Enqueue('E'): rear = ( 3 + 1 ) MOD 5 = 4; Q[4] = 'E'; size = 4.
- 7.Step 7: Enqueue('F'): rear would be ( 4 + 1 ) MOD 5 = 0; Q[0] = 'F'; size = 5 (Queue is now full).
- 8.Step 8: Check boundary conditions: Array length is 5 and current size = 5. All items successfully enqueued because Dequeue opened index 0 for circular reuse.
Question: Explain the process of inserting the value 17 into an existing Binary Search Tree (BST) with root 15, left child 8 (which has right child 12), and right child 23 (which has left child 19). Write down the comparison steps and the final pointer assignment.
- 1.Step 1: Compare 17 with root node 15. Because 17 > 15, traverse to the right subtree (node 23).
- 2.Step 2: Compare 17 with node 23. Because 17 < 23, traverse to the left subtree (node 19).
- 3.Step 3: Compare 17 with node 19. Because 17 < 19, examine the left pointer of node 19.
- 4.Step 4: Identify that the left child pointer of node 19 is null (empty).
- 5.Step 5: Allocate memory for a new node with key 17, and set node 19's left child pointer to reference this new node.