AQA A-Level Computer Science Paper 1, June 2025: Question 1
11 marks · Medium difficulty · Short Answer
Explain principles of hash tables and their operations, compare linear and binary search complexities, and evaluate tractability and passes for sorting algorithms.
Practise this questionQuestion
Question text
01 Two data structures that can be used to store a collection of data records are a hash
table and a sorted list.
01.1 Explain why a record in a hash table can normally be found more quickly than a
record in a sorted list.
[1 mark]
01.2 Describe the steps involved in adding a new record to a hash table.
[4 marks]
01.3 Explain why the time taken to find a specific record in a hash table can increase when
lots of records are stored in the table.
[1 mark]
Linear search and binary search are two algorithms that could be used to find a record
in a sorted list.
01.4 Explain why the linear search algorithm has time complexity of O(n).
[1 mark]
01.5 Explain why the binary search algorithm has time complexity of O(log n).
[1 mark]
01.6 State one advantage of a linear search compared to a binary search.
[1 mark]
If the list of records was unsorted, a bubble sort algorithm or a merge sort algorithm
could be used to sort the records.
01.7 Explain why both these sorting algorithms are tractable.
[1 mark]
01.8 After how many passes is bubble sort guaranteed to have sorted any list of
100 items?
Mark scheme
Show the mark scheme
Question Marks
01 1 Mark is for AO1 (understanding) 1
Hashing algorithm/function will determine the memory location/index used;
No need to search through records to find the required one;
Max 1
01 2 All marks AO1 (understanding) 4
1. Apply hashing algorithm/function;
2. To (unique/primary) key; NE. data
3. Insert data at the index (A. address/memory location) obtained from this
process;
4. If there is already data there, use a suitable method for collision handling;
A. by example
01 3 Mark is for AO1 (understanding) 1
More collisions occur meaning direct access will not happen as frequently // more
collisions occur meaning more items will not be stored at the calculated index
(A. address/memory location) (given by the hashing function/algorithm);
NE. more collisions occur
A. description of a collision resolution method being used, eg need for a linear
search if multiple results have the same result from the hashing function
01 4 Mark is for AO1 (understanding) 1
As list increases in size the maximum number of comparisons increases at the
same rate;
A. in the worst case, n comparisons will be needed
NE. n comparisons are needed
01 5 Mark is for AO1 (understanding) 1
As list increases in size the maximum number of comparisons increases at a
decreasing rate;
Each comparison halves the number of remaining items that need to be considered
// each comparison halves the size of the list that has to still be searched through;
01 6 Mark is for AO1 (understanding) 1
– A-LEVEL COMPUTER SCIENCE – –
Can be used on unsorted lists;
01 7 Mark is for AO1 (understanding) 1
Both have polynomial (or better) time complexity;
Neither have exponential (or worse) time complexity;
As the size of the list grows, the increase in the time taken is reasonable;
Max 1
01 8 Mark is for AO2 (apply) 1
99;
How to answer it
Data Structures & Complexity: Hash Tables, Searching & Sorting
This question examines core knowledge of hash tables (direct addressing, record insertion, collision generation and resolution), time complexity of searching algorithms (linear vs. binary search in Big-O notation), practical advantages of searching methods, algorithm tractability, and the operational mechanics of bubble sort.
Direct Access in Hash Tables vs. Sorted Lists
Explain why a record in a hash table can normally be found more quickly than a record in a sorted list.
✅ Acceptable Answers (Any 1)
- The hashing algorithm/function calculates/determines the exact memory location/index used directly.
- There is no need to search through or compare other records to find the required item (direct access / O(1) lookup).
🧠 Exam Technique
Highlight the contrast: sorted lists require sequential or divide-and-conquer comparisons (e.g. O(log n)), whereas a hash table uses key computation to jump directly to the slot without comparisons.
Insertion Procedure in a Hash Table
Describe the steps involved in adding a new record to a hash table.
✅ 4-Step Process (1 mark per step)
- Apply the hashing algorithm/function;
- Apply it specifically to the unique/primary key of the record;
- Insert/store the data at the calculated index (or address/memory location);
- If the slot is already occupied (a collision), use a suitable method for collision handling (e.g., linear probing or rehashing).
❌ Common Errors
- Vague input: Saying "hash the data" instead of "hash the key / primary key" scores 0 for step 2.
- Omitting collision handling: Forgetting to describe what happens when a target slot is already filled.
High Load Factor & Retrieval Degradation
Explain why the time taken to find a specific record in a hash table can increase when lots of records are stored in the table.
✅ Acceptable Answers
- More collisions occur, meaning direct access will not happen as frequently / items will not be located at their initial hashed index.
- More collisions require collision resolution methods (such as linear probing/searching through synonym chains), which takes extra time.
❌ Examiner Pitfall
Writing only "more collisions occur" is Not Enough (NE). You must state the consequence: direct addressing fails, requiring searching/probing along collision paths.
Time Complexity of Linear Search: O(n)
Explain why the linear search algorithm has time complexity of O(n).
✅ Acceptable Answers
- As the list increases in size, the maximum number of comparisons increases at the same rate (direct linear proportion).
- In the worst case, all n items must be examined/compared.
❌ Common Error
Stating simply "it takes n comparisons" is Not Enough (NE). You must qualify this as the worst-case scenario or explain the proportional growth rate.
Time Complexity of Binary Search: O(log n)
Explain why the binary search algorithm has time complexity of O(log n).
✅ Acceptable Answers
- Each comparison halves the number of remaining items that need to be considered (or halves the remaining search space).
- As list size increases, the maximum number of comparisons increases at a decreasing rate (logarithmic growth).
💡 Key Knowledge
Because the search space is divided by 2 after each probe (repeated division), the number of steps required to reduce n items to 1 is log₂ n .
Advantage of Linear Search over Binary Search
State one advantage of a linear search compared to a binary search.
✅ Accepted Answer
It can be used on unsorted / unordered lists (data does not need to be sorted prior to searching).
🧠 Exam Technique
Binary search strictly requires pre-sorted data. Sorting an unsorted list takes at best O(n log n), making a one-off linear search (O(n)) far more efficient when data is unordered.
Tractable Algorithms
Explain why both these sorting algorithms are tractable.
✅ Acceptable Answers (Any 1)
- Both have polynomial (or better) time complexity (e.g. O(n²) for bubble sort, O(n log n) for merge sort).
- Neither has exponential (or factorial) time complexity.
- As the size of the list grows, the increase in time taken is reasonable / solvable in polynomial time.
💡 Key Term: Tractability
A problem/algorithm is tractable if it can be solved within polynomial time, O(nᵏ) for some constant k . Intractable algorithms require exponential (e.g. O(2ⁿ) ) or factorial time.
Bubble Sort Worst-Case Passes
After how many passes is bubble sort guaranteed to have sorted any list of 100 items?
📐 Calculation Steps
- Let the number of items be n = 100 .
- In each pass through the list, at least one item (the largest unsorted value) bubbles to its final correct position.
- Once n - 1 items are placed in their correct positions, the final 1 item is naturally positioned correctly.
- Number of passes = n - 1 = 100 - 1 = 99 .
✅ Final Answer
99
❌ Common Error
Answering 100. Remember that a list of n elements requires at most n - 1 complete passes.
Topics
4.2 Fundamentals of data structures · 4.3 Fundamentals of algorithms · 4.4 Theory of computation · 4.2.6 Hash tables · 4.3.4 Searching algorithms · 4.3.5 Sorting algorithms · 4.4.4 Classification of algorithms
Question and mark scheme from the AQA A-Level Computer Science examination, Paper 1, June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.