Edexcel GCSE Computer Science June 2025 Paper 1, Question 5(d) and (e): efficiency and a binary search table
Pearson Edexcel 1CP2/01 June 2025, Question 5(d) and (e): explain the worst case of a linear search and the best case of a bubble sort, then fill in the start, end and mid-point table for a binary search that looks for 78 and does not find it. Worked through, with the search to run.
The last two parts of Question 5 on the Pearson Edexcel GCSE Computer Science Paper 1 sat on 12 May 2025 (1CP2/01) are about how algorithms behave: two explanations (4 marks) and a binary search table for a value that is not there (6 marks). Parts (a) to (c) are on the previous page.
We do not copy the paper here. Open it beside this page: Edexcel June 2025 Paper 1 question paper (PDF). When you have finished, check the mark scheme too.
Part (d): best and worst cases (2 + 2 marks)
Each is a linked pair: the case, and why.
- Worst case for a linear search: when the target is the last item or not in the array at all, because every item has to be compared with the target.
- Best case for a bubble sort: when the array is already in order, because only one pass is needed: no swaps happen, so the sort can tell it is finished.
Part (e): binary search for 78 (6 marks)
The array has eleven values at index 0 to 10: 11, 22, 33 ... 99, 100, 101. Fill in a table of the start index, end index, the mid-point calculation, whether the target is found, and which half is discarded.
Use (start + end) // 2 for the mid-point, and show the sum.
| Start | End | Mid-point | Found | Discard |
|---|---|---|---|---|
| 0 | 10 | (0 + 10) // 2 = 5 | N | lower |
| 6 | 10 | (6 + 10) // 2 = 8 | N | higher |
| 6 | 7 | (6 + 7) // 2 = 6 | N | lower |
| 7 | 7 | (7 + 7) // 2 = 7 | N | higher |
Row by row: the value at 5 is 66, less than 78, so the lower half goes and the start becomes 6. At 8 it is 99, more than 78, so the higher half goes and the end becomes 7. At 6 it is 77, less, so start becomes 7. At 7 it is 88, more, so end becomes 6. Now the start is past the end, and the search stops: 78 is not in the array.
Rounding the mid-point up instead is accepted, and gives 7 then 6 in the last two rows.
Where the marks are lost
- "When the target is not there" with no reason. The second mark of each pair is the because.
- Writing just the mid-point. The question says show the calculation. One mark is lost, once, if you do not.
- Discarding the wrong half. 66 is less than 78, so everything at or below index 5 goes: the lower half.
- Stopping after two rows. The search continues until the start passes the end.
Run it
The search, printing each row of the table. Change TARGET to a value that is in the array and to values at each end.
The program
from bugbot import *
connect()
# change TARGET and press Run
TARGET = 78
values = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 101]
start = 0
end = len(values) - 1
found = False
print("start end mid found discard")
while start <= end and not found:
mid = (start + end) // 2
if values[mid] == TARGET:
found = True
print(start, end, mid, " Y")
elif values[mid] < TARGET:
print(start, end, mid, " N lower")
start = mid + 1
else:
print(start, end, mid, " N higher")
end = mid - 1
if found:
led("green")
print("found at index", mid)
else:
led("red")
print(TARGET, "is not in the array")
Questions
What is the answer to Edexcel 2025 Paper 1 Question 5(e)?
Four rows: start 0 end 10 mid 5 discard lower; start 6 end 10 mid 8 discard higher; start 6 end 7 mid 6 discard lower; start 7 end 7 mid 7 discard higher. 78 is not found.
What is the worst case for a linear search?
The target is the last item, or is not in the array, so every item has to be compared with it.
What is the best case for a bubble sort?
The array is already sorted, so a single pass makes no swaps and the algorithm can stop after one pass.
More from this paper
Every Edexcel 1CP2 question we have worked · Guide: Linear search and binary search explained
Learn it step by step
- F5.6 Binary search Algorithms
- F5.5 Linear search Algorithms
- F5.7 Bubble sort Algorithms
This is our own explanation of a published exam question. It is not written or endorsed by Pearson, and the question paper and mark scheme remain Pearson's copyright. Read them on Pearson's site with the links on this page.