Comparing the complexity of algorithms – OCR A Level Computer Science lesson (H446)
Students learn to compare algorithms by their best-case and worst-case time and their space, applying the comparison to a given data set.
Lesson 4 of 16 in unit 13.2 Big O and Project Design, taught in Year 13, Autumn 1. It answers one big question: Which algorithm should we choose for this data, and why?
By the end, students can compare algorithms by their best-case and worst-case time and their space, applying the comparison to a given data set.
- The Build (the main task)
- Compare merge sort and insertion sort for sorting Lumenfield Observatory's nightly list of new observations, which arrives almost in time order, covering best-case time, worst-case time and memory used (6 marks).
- Support version
- A comparison grid with rows for best case, worst case and space and a 'whereas' column, with the merge sort column filled in; students complete insertion sort and write each row as one sentence covering both.
- Challenge
- Quick sort is suggested instead. Explain what happens to quick sort's time if it always picks the first item as the pivot and the observations arrive already sorted.
- Real-world link
- Lumenfield Observatory's overnight job that sorts the night's new observations into time order before they are added to the catalogue.
- Key words
- Best case, Worst case and Compare, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “The best case is when the input is small, such as one item”; “Each algorithm has one complexity that is true for every input”.
- OCR H446 specification
- 2.3.1 (b); (d).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Students can do it all on paper.
Also sold in the Big O and Project Design unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for A Level Computer Science
See allStudents learn to explain why algorithms are compared by how their steps grow with n, and reduce a step-count formula to its Big O.
Free sample lessonStudents learn to identify O(1), O(n) and O(n²) code from its loops and explain each answer from how often the statements run.
Students learn to explain logarithmic and exponential growth in terms of halving and doubling, and say why exponential algorithms do not scale.
Written for the specifications named. Not endorsed by or affiliated with any exam board.