Homework · Assigned

Bubble sort: Q9(a) and the bubble-sort part of Q10

Due 7 Oct 2026 · Q9(a) + Q10 (bubble sort only)

Complete Q9(a) on printed page 11 and only the bubble-sort part of Q10 on printed page 12 of the B2.4 Algorithms student handout. Due 7 October 2026.

Your tasks

Task 1

Q9(a): debug bubble sort

Use printed page 11. Identify and explain the problem with resetting swapped outside the outer loop, and correct the bubble-sort code as requested in Q9(a).

Task 2

Q10: trace bubble sort only

Use printed page 12. Trace bubble sort on [4, 2, 3, 1], recording the passes, comparisons and swaps requested in Q10. The selection-sort portion is not assigned.

Assignment checklist

  • Q9(a): the corrected bubble-sort code and explanation.
  • Q10: the bubble-sort trace, including passes, comparisons and swaps.

Due Wednesday, 7 October 2026. This task assigns Q9(a) and the bubble-sort part of Q10 only; Q8, other parts of Q9 and the selection-sort part of Q10 are not included.

If you need help

Use the sorting lesson and bubble-sort animation for support. Follow the page numbers printed on the handout. The separate holiday assignment, questions 3–7, remains due 12 October.