Mathster Maths topics Free worksheets Coverage Mathster for schools

Maths topics › A level Further Maths › D1 and algorithms

Sort a list using a quick sort

A level Further Maths · D1 and algorithms

A question

Use a quick sort to arrange this list of \(8\) items into descending order. In each list or sublist the pivot is the middle item, item \(\dfrac{n+1}{2}\) rounded up.

\(41, 24, 46, 53, 43, 84, 34, 28\)

Write down the list at the end of each pass and mark the pivots used in that pass.

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. The list has \(n = 8\) items. The pivot is in position \(\dfrac{ 8 + 1}{ 2} = 4.5\), which rounds up to 5, so the first pivot is 43.
  2. For descending order, the items larger than the pivot are written before it. The items larger than 43, in their original order, are 46, 53, 84.
  3. So after the first pass there are 3 items before the pivot.

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.