Community resourceWorksheet
J277 2.1.3 Bubble and insertion sorting
Part 2 of 4 · J277 2.1.3 · Searching and sorting
Bubble sort and insertion sort, traced by hand one pass at a time.
Students will:
- describe the steps of a bubble sort
- describe the steps of an insertion sort
- carry out one pass of each by hand
- apply both algorithms to given data
- recognise each algorithm from code
Inside: 4 explanation cells, 2 runnable Python tasks, 4 multiple-choice questions and 4 written answers. 18 marks, about 60 minutes.
Series: J277 2.1.3 · Searching and sorting, part 2 of 4.
Shared by Coding PathwayVerified teacher
- 14 cells
- About 60 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
- Updated 9 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Bubble and insertion sorting
Sorting places data into an order. Bubble sort repeatedly compares adjacent values and swaps those in the wrong order. Insertion sort takes the next unsorted value and inserts it into the correct position in a growing sorted section. OCR expects the steps, application and recognition of both algorithms; the focus is understanding and tracing the method, not memorising a full implementation.
Which action is characteristic of bubble sort?
- ACompare adjacent items and swap them when they are in the wrong order
- BSelect the middle item and discard half
- CSplit until single items and merge
- DCheck one target from the start
Bubble sort
During a pass, adjacent values are compared and swapped if they are in the wrong order. Repeated passes continue until no swaps are needed. In ascending order, a large unsorted value moves towards the right during a pass.
Insertion sort
Insertion sort treats the left part as sorted. It takes the next unsorted value, shifts larger sorted values to the right and inserts the value in its correct place. The sorted section grows by one item each pass.
The diagram shows one characteristic action, not a complete sort. Bubble sort continues comparing the next adjacent pair; insertion sort repeats with the next value outside the sorted section.
Before running the bubble-sort example, work through the three adjacent comparisons using the updated list after each swap. Predict the list after this single pass; do not continue sorting it to completion.
# One bubble-sort pass
values = [7, 3, 5, 2]
for index in range(len(values) - 1):
if values[index] > values[index + 1]:
temporary = values[index]
values[index] = values[index + 1]
values[index + 1] = temporary
print(values)
What is the list after one complete ascending bubble-sort pass through [7, 3, 5, 2]?
- A[2, 3, 5, 7]
- B[3, 5, 2, 7]
- C[3, 7, 5, 2]
- D[7, 3, 2, 5]
Show the list after each swap in the first ascending bubble-sort pass through [6, 2, 4, 1].
Use the updated list for the next adjacent comparison. Do not continue into a second pass.
Students type their answer here.
Worked example: one insertion-sort pass
The left section [2, 5, 8] is already sorted. The next value is 4. Run the example to see larger values shift right until the correct insertion position becomes available.
Follow current and position carefully: current preserves the value being inserted while position moves left through the sorted section.
# One insertion-sort pass: insert the value at index 3
values = [2, 5, 8, 4, 7]
current = values[3]
position = 3
while position > 0 and values[position - 1] > current:
values[position] = values[position - 1]
position = position - 1
values[position] = current
print(values)
In insertion sort, what is true before the next unsorted value is inserted?
- AThe right-hand section is always empty
- BEvery value is already sorted
- CThe left-hand section being inserted into is sorted
- DAdjacent values have never been compared
The sorted section is [3, 6, 9] and the next value is 5. Describe the shifts and insertion performed by insertion sort.
Work right to left through the sorted section until the insertion position is found.
Students type their answer here.
Explain why a condition-controlled loop is suitable for moving the current value left during an insertion sort.
Consider whether the number of shifts is known before the insertion begins and what condition should stop the movement.
Students type their answer here.
A code listing has an outer loop that grows a sorted left section and an inner loop that shifts larger values right. Which sort is it?
- AMerge sort
- BBubble sort
- CBinary search
- DInsertion sort
Compare bubble sort and insertion sort by describing one pass of each. Your answer should make the difference between swapping adjacent values and inserting into a sorted section clear.
Use the vocabulary adjacent comparison, swap, sorted section, shift and insert where appropriate.
Students type their answer here.
Review
Recognise bubble sort by repeated adjacent comparisons and swaps. Recognise insertion sort by a growing sorted left section into which the next value is inserted. When applying either method, show the state of the data at the exact points requested rather than jumping straight to the fully sorted answer.