Maths topics › A level Further Maths › D1 and algorithms
Find the order of an algorithm and use it to estimate how long the algorithm will take
A question
Free worksheet
10 questions on this objective, ready to print.
Download the worksheet (PDF)Worked solution
The working
- (a) In the worst case the passes make \(34, 34 - 1, \ldots, 2, 1\) comparisons, a total of \(\dfrac{1}{2}n(n-1) = \dfrac{1}{2} \times 35 \times 34 = 595\).
- (b) \(\dfrac{1}{2}n(n-1) = \dfrac{1}{2}n^2 - \dfrac{1}{2}n\). The \(n^2\) term dominates, so the bubble sort has quadratic order.
- (c) For quadratic order the time is multiplied by about \(10^2 = 100\).
- (d) One algorithm is carried out after the other, so their times add. The higher order dominates the sum: the process has order \(n^2\). (Orders are multiplied only when one algorithm is carried out inside the other.)
Answer: (a) 595 (b) quadratic (c) 100 (d) n^2
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.