Phase 1: Prepare
Step 1 Warm-up recall
From M5.L2: doubling n for a quadratic method?
Private: nothing you type here is sent or stored.
Step 2 Learning goal
By the end of this lesson you can:
- compute the cost of two methods at the same n (Foundation);
- find a crossover point (Core);
- choose a method for a stated workload (Core).
Phase 2: Teach
Step 3 A familiar example
A method with a heavy set-up but slow growth loses on tiny inputs and wins on large ones. Growth rate decides which in the end, but your actual input size decides which today.
Step 4 Clear explanation
Two methods can be compared by computing their step counts at the same input size. Take two invented methods: method A costs 100 × n steps (linear, with a large constant), and method B costs n × n steps (quadratic, with none).
| n | Method A: 100 × n steps | Method B: n × n steps | Fewer steps |
|---|---|---|---|
| 10 | 1,000 | 100 | B |
| 100 | 10,000 | 10,000 | Equal |
| 1,000 | 100,000 | 1,000,000 | A |
For small n, B is cheaper; they are equal at n = 100; beyond that, A is cheaper, and the gap widens. The point where the lines cross is the crossover. To decide, find your expected n. If a task will only ever handle 50 items, B is better today. If it may grow to thousands, choose A. Growth rate wins in the long run, but input size decides in practice. A programmer working in any programming language faces the same choice between a simple method and a scalable one.
Step 5 Worked example (4 marks)
For methods A (100 × n) and B (n × n), which is cheaper at n = 500 and by how much?
- A: 100 × 500 = 50,000. (1 mark)
- B: 500 × 500 = 250,000. (1 mark)
- A is cheaper. (1 mark)
- Answer: A, by 200,000 steps. (1 mark)
Phase 3: Practise
Step 6 Learner practice (instant-marked)
1. The crossover is the input size at which:
Beyond it the order of the two methods changes.
2. For A = 100n and B = n×n, at n = 10 the cheaper is:
B costs 100 and A costs 1,000.
3. For A = 100n and B = n×n, at n = 1,000 the cheaper is:
A costs 100,000 and B costs 1,000,000.
4. A task will only ever handle 50 items. Which is cheaper?
B costs 2,500 and A costs 5,000.
Phase 4: Close
Step 7 Recap
- Compute both costs at your expected n.
- The crossover is where the methods cost the same.
- Growth wins in the long run; input size decides today.
Step 8 Exit ticket (ungraded)
Find the cost of A and B at n = 20 and say which is cheaper.
Private: nothing you type here is sent or stored.
Step 9 Go further (Extension)
Describe a task whose input may grow and say why you would choose the slower-growing method.
Common mistakes
| Mistake | Why it fails |
|---|---|
| Choosing on growth alone | Check the input size you really expect. |
| Comparing at different n | Use the same n for both methods. |
| Ignoring the constant factor | A large constant shifts the crossover. |
Limits. Methods A and B are invented for illustration; real constants must be measured.