Single lesson · Written for OCR A Level (H446)

Linear search – OCR A Level Computer Science lesson (H446)

Students learn to write a linear search as a function in Python and OCR pseudocode, and state its best and worst cases.

Also in a bundle Searching, Sorting and Recursion – OCR A Level Computer Science lessons (H446) 15 lessons for £45 · save 25% on buying separately

Lesson 3 of 15 in unit 12.4 Searching, Sorting and Recursion, taught in Year 12, Autumn 2. It answers one big question: How does a computer find an item in an unsorted list?

By the end, students can write a linear search as a function in Python and OCR pseudocode, and state its best and worst cases.

The Build (the main task)
Write a function linearSearch(uploads, title) in Python and OCR pseudocode that returns the index of a track title in Tidewave Audio's unsorted list of today's uploads, or -1 if it is not there (5 marks).
Support version
A Parsons problem: the lines of the function in jumbled order, with the function header and the final return -1 already placed.
Challenge
State the best-case and worst-case number of comparisons for Tidewave Audio's 50 000 daily uploads, and explain why sorting the list first would not pay off for a single search (3 marks).
Real-world link
Tidewave Audio, an independent music-streaming service, receives thousands of new tracks a day from small labels: the unit's running context.
Key words
Linear search, Algorithm and Systematic, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Linear search only works on sorted data”; “The function should return -1 as soon as one item does not match”.
OCR H446 specification
2.3.1 (a); (f).

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 need computers for the main task.

Also sold in the Searching, Sorting and Recursion 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.