Single lesson · Written for OCR A Level (H446)

Constant, linear and polynomial complexity – OCR A Level Computer Science lesson (H446)

Students learn to identify O(1), O(n) and O(n²) code from its loops and explain each answer from how often the statements run.

Also in a bundle Big O and Project Design – OCR A Level Computer Science lessons (H446) 16 lessons for £45 · save 29% on buying separately

Lesson 2 of 16 in unit 13.2 Big O and Project Design, taught in Year 13, Autumn 1. It answers one big question: Which code patterns grow steadily, and which explode?

By the end, students can identify O(1), O(n) and O(n²) code from its loops and explain each answer from how often the statements run.

The Build (the main task)
State the time complexity of four Lumenfield Observatory code fragments and explain each answer from its loops: (a) reading star[i] from an array, (b) one loop over all n stars to find the brightest, (c) two loops over all n stars, one after the other, (d) a loop over all n stars nested inside another loop over all n stars to find every close pair (8 marks).
Support version
A trace table for each fragment with n = 4 and n = 8, where students count how many times the innermost line runs, then match the counts to O(1), O(n) or O(n²).
Challenge
A fifth fragment loops over all n stars and, inside it, loops over the 12 months of the year. State its complexity and explain why it is not O(n²).
Real-world link
Lumenfield Observatory's programs that read a star's record, find the brightest star and look for pairs of stars that sit close together in the sky.
Key words
Constant complexity, Polynomial complexity and Grow, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“O(1) means the algorithm takes exactly one step”; “Any code with two loops is O(n²)”.
OCR H446 specification
2.3.1 (c).

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 all

Written for the specifications named. Not endorsed by or affiliated with any exam board.