Community resourceWorksheet
1CP2-CT-8.5 Tracing debugging sorting and searching checkpoint
Part 5 of 5 · 1CP2-CT-8 · Tracing, debugging, sorting and searching
This checkpoint assesses the CT-8 series only. Recall: a trace records changed state in execution order; syntax, runtime and logic errors differ; bubble sort compares adjacent items; binary search requires sorted data and discards half of its remaining range.
Students will:
- complete a formal trace with reduced support
- apply bubble sort and binary search by hand
- diagnose a logic error from evidence
- amend and retest a search program
Inside: 5 explanation cells, 1 fill-in-the-blanks cell, 2 multiple-choice questions, 1 trace table, 5 written answers and 1 Python task. 20 marks, about 45 minutes.
Series: 1CP2-CT-8 · Tracing, debugging, sorting and searching, part 5 of 5.
Shared by Coding PathwayVerified teacher
- 15 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Tracing, debugging, sorting and searching checkpoint
This checkpoint assesses the CT-8 series only. Recall: a trace records changed state in execution order; syntax, runtime and logic errors differ; bubble sort compares adjacent items; binary search requires sorted data and discards half of its remaining range.
- adjacent
- logic
- sorted
- syntax
In a trace where blank means unchanged, what does an empty total cell show?
- Atotal became zero
- Btotal kept its previous value
- Ctotal was printed
- Dtotal was deleted
Complete the trace table.
Follow the loop and selection in order; record output only when print executes.
Use one row for each pass through the loop. Fill in a box only when that value changes on that row, and leave the rest blank.
total = 0for value in [6, 2, 7]:if value > 4:total = total + valueprint(total)
| Row | total | value | value > 4 | Output |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 |
Define a runtime error and give one valid programming example.
Your definition must describe execution, not speed.
Students type their answer here.
Apply bubble sort
Use ascending order and show the state after a complete pass. Remember: compare neighbours from left to right and swap only an out-of-order pair.
Show [9, 4, 7, 2, 6] after one complete ascending bubble-sort pass and state how many comparisons were made.
Record the list after all adjacent comparisons in the pass.
Students type their answer here.
Explain why a complete bubble-sort pass with no swaps is evidence that the list is sorted.
Link every adjacent comparison to order.
Students type their answer here.
Apply binary search
Search only within the current inclusive low to high range. Once a middle item has been checked and is unequal, exclude it when updating the relevant boundary.
Apply binary search to find 38 in [6, 12, 19, 25, 31, 38, 44, 51, 60]. State the compared values in order.
Use integer middle positions.
Students type their answer here.
A list changes often and is currently unsorted. Which statement about binary search is correct?
- AIt can be applied immediately
- BThe list must first be sorted, and that preparation cost matters
- CIt compares adjacent pairs
- DIt always uses one comparison
Diagnose, amend and retest
The function should return the position of target in a sorted list, or -1 if absent. The upper-bound update contains a logic error.
def binary_position(values, target):
low = 0
high = len(values) - 1
while low <= high:
middle = (low + high) // 2
if values[middle] == target:
return middle
elif values[middle] < target:
low = middle + 1
else:
high = middle + 1 # fault
return -1
answer = binary_position([4, 8, 15, 16, 23, 42], 8)
print(answer)Give one not-found test for binary_position, with its expected result.
Use a sorted list and an absent target.
Students type their answer here.
Route forward
You have secured formal tracing, evidence-led debugging and the two standard algorithms. Later CT series will reuse these methods inside larger programs and testing cycles.