Mathster Maths topics Free worksheets Coverage Mathster for schools

Maths topics › A level Further Maths › D1 and algorithms

Sort a list using a bubble sort

A level Further Maths · D1 and algorithms

Try a question

A list of \( 96 \) items is to be sorted into ascending order with a bubble sort. The sort stops after a pass in which no swaps are made.

(a) What is the fewest passes the sort could need?  

(b) What is the most passes the sort could need?  

Free worksheet

10 questions on this objective, ready to print.

Download the worksheet (PDF)

We use this address to send you the answers, and for news only if you tick the box.

Worked solution

The working

  1. (a) If the list is already in ascending order, pass 1 makes no swaps, so the sort stops: 1 pass.
  2. (b) If the smallest item starts at the end, it moves only one place forward in each pass, so it needs 95 passes to reach the front. Counting one more pass that makes no swaps gives 96 passes, the answer expected here.
  3. Answers: (a) 1; (b) 96.

Answer: a) 1 b) 96

Mathster is maths homework, practice and assessment for schools, with animated worked solutions. Try Mathster free for 60 days →

Objectives from the AS and A level subject content for further mathematics (Department for Education). Contains public sector information licensed under the Open Government Licence v3.0.