✦ Created by our AI question engine · answers checked by script
Self-marked 0 / 9
How this page works
Full help
- Read the question and the information above the parts.
- Write your working and your answer in the box for each part, with units, as in the exam. Press Enter for a new line.
- Check your final line with Check my answer. Use the calculator on the right when you need it.
- Mark yourself: open the markscheme and tick each mark you earned.
At a sports day in Leicester, five runners record their 100 m times in seconds. The times are entered in this order:
| Zara | Tom | Inés | Kai | Ruth |
|---|---|---|---|---|
| 14.2 | 12.8 | 15.1 | 11.9 | 13.4 |
Mr Novak uses a bubble sort to put the times in order, quickest first.
- One pass: compare the 1st and 2nd times and swap them if the first is larger. Then compare the 2nd and 3rd times, and so on, until the last two times have been compared.
- Repeat passes until a pass makes no swaps. Then stop.
443.1
[1]Write down how many comparisons are made in one pass through the five times.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 1 mark
Model answer
Pairs 1–2, 2–3, 3–4, 4–5: 4 comparisons.
4
Mark yourself
443.2
[2]Find the number of swaps made in the first pass.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 2 marks
Model answer
14.2 > 12.8 swap → 12.8, 14.2, 15.1, 11.9, 13.4. 14.2 < 15.1 no swap. 15.1 > 11.9 swap → …, 11.9, 15.1, 13.4. 15.1 > 13.4 swap. 3 swaps.
3
Mark yourself
443.3
[2]Put the times in the order they are in after the first pass.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 2 marks
Model answer
After the first pass: 12.8, 14.2, 11.9, 13.4, 15.1.
12.8, 14.2, 11.9, 13.4, 15.1
Mark yourself
443.4
[2]Find the total number of passes the algorithm makes, including the final pass with no swaps.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 2 marks
Model answer
Pass 2: 12.8, 11.9, 13.4, 14.2, 15.1 (2 swaps). Pass 3: 11.9, 12.8, 13.4, 14.2, 15.1 (1 swap). Pass 4: no swaps, so stop. 4 passes.
4
Mark yourself
443.5
[2]Explain why, after the first pass, the largest time is always at the end of the list, whatever order the times start in.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 2 marks
Model answer
Once the largest time is reached, it is larger than every time after it, so it is swapped at every later comparison. It is carried along to the last position.
The largest time is swapped at every comparison after it is reached, so it is carried to the end.
Mark yourself
443.6
[2]In a later race, six times are entered already in order, quickest first. Find the total number of comparisons the bubble sort makes before it stops.
Checks your final line. Mark a different line with ★ if your answer is not the last line.
Markscheme · 2 marks
Model answer
The first pass makes 6 − 1 = 5 comparisons and no swaps, so the algorithm stops after one pass. Total 5 comparisons.
5