Single lesson · Written for OCR A Level (H446)

Coding stacks and queues – OCR A Level Computer Science lesson (H446)

Students learn to program a circular queue with overflow and underflow checks and test it with boundary data.

Also in a bundle Data Structures – OCR A Level Computer Science lessons (H446) 15 lessons for £45 · save 25% on buying separately

Lesson 5 of 15 in unit 12.8 Data Structures, taught in Year 12, Spring 2. It answers one big question: How do we know our stack and queue code is safe?

By the end, students can program a circular queue with overflow and underflow checks and test it with boundary data.

The Build (the main task)
Write a Python class for Tillbrook's returns desk: a circular queue of 5 returns whose enqueue and dequeue report overflow and underflow, then test it when empty, full and holding one item (8 marks).
Support version
A part-written program with the class, constructor and dequeue done; students complete enqueue from the OCR pseudocode printed beside it and fill in a given test table.
Challenge
Write the van stack as a class too, and use it to reverse the order of a day's returns taken from the queue.
Real-world link
Tillbrook's returns desk queue, then the van stack from lesson 3.
Key words
Underflow, Front pointer and Boundary, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Underflow and overflow are the same error”; “Dequeue moves the front pointer and then reads the item”.
OCR H446 specification
1.4.2 (c); 2.3.1 (e) (algorithms for the main data structures: stacks, queues, trees and linked lists, with depth-first (post-order) and breadth-first traversal of trees).

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 Data Structures 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.