Single lesson · Written for OCR A Level (H446)

Recursive binary search – OCR A Level Computer Science lesson (H446)

Students learn to write a recursive binary search with two base cases, and verify by tracing that it terminates when the target is absent.

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 12 of 15 in unit 12.4 Searching, Sorting and Recursion, taught in Year 12, Autumn 2. It answers one big question: How do you write binary search recursively, and check it stops?

By the end, students can write a recursive binary search with two base cases, and verify by tracing that it terminates when the target is absent.

The Build (the main task)
Write a recursive binary search function in Python and OCR pseudocode that returns the position of an artist ID in Tidewave Audio's sorted artist list, or -1 if it is absent (6 marks).
Support version
Part-filled code: the header and both base cases are given; students write the midpoint and the two recursive calls with their new low and high.
Challenge
Trace your function for an absent ID in a list of eight artist IDs, recording low, high and mid for each call, to verify that it terminates (4 marks).
Real-world link
Tidewave Audio's app looks up an artist's ID when a listener taps their name.
Key words
Recursive algorithm, Termination and Verify, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Calling the function recursively is enough; the call does not need to be returned”; “If the target is absent, the function will stop by itself”.
OCR H446 specification
2.2.1 (b) (recursion: how it can be used, and how it compares with an iterative approach); 2.3.1 (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.