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).
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.
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).
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.
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.
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.