Single lesson · Written for OCR A Level (H446)

Bubble sort – OCR A Level Computer Science lesson (H446)

Students learn to write a bubble sort that uses a temporary variable to swap and a flag to stop early, and trace each pass.

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 5 of 15 in unit 12.4 Searching, Sorting and Recursion, taught in Year 12, Autumn 2. It answers one big question: How does bubble sort put a list in order?

By the end, students can write a bubble sort that uses a temporary variable to swap and a flag to stop early, and trace each pass.

The Build (the main task)
Write a bubble sort in Python and OCR pseudocode that sorts Tidewave Audio's daily play counts into descending order, using a temporary variable for each swap and a flag to stop when a pass makes no swaps (6 marks).
Support version
Part-filled code: the outer WHILE loop and the comparison are given; students complete the three swap lines and the two flag lines.
Challenge
Explain how reducing the inner loop by one item on each pass saves comparisons, and calculate the comparisons saved for 10 items (4 marks).
Real-world link
Tidewave Audio builds a daily chart by putting play counts in descending order.
Key words
Bubble sort, Swap and Pass, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Two items can be swapped with a = b then b = a”; “One pass sorts the whole list”.
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.