Linear search – AQA GCSE Computer Science lesson (8525)
Pupils learn to explain how a linear search works and write one in the class's language.
Lesson 5 of 11 in unit 10.5 Compression, Networks and Searching, taught in Year 10, Summer 1. It answers one big question: How does a computer find an item in a jumbled list?
By the end, pupils can explain how a linear search works and write one in the class's language.
- The Build (the main task)
- Explain how a linear search would find a title in the returns trolley list. (3 marks) Write a program that inputs a book title and uses a linear search of the list books to output True if the title is on the trolley and False if it is not. You must not use a built-in search function. (6 marks)
- Support version
- Part-filled code with the loop and found flag set up; pupils write the comparison and the output.
- Challenge
- Change your program so that it outputs the position (index) of the title in the list, or -1 if the title is not on the trolley. (4 marks) Complete a trace table (i, books[i], found) for the AQA pseudo-code linear search when the title entered is Blue Fox, and state the output. (4 marks) Write a program that keeps asking the user for a title until they enter one that is on the trolley (use a linear search of books, not a built-in search), then outputs Found it. (6 marks)
- Real-world link
- Searching the returns trolley, which is in no order, for one book.
- Key words
- Linear search, Found flag and Unordered, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “A linear search only works on a sorted list”; “The result should be output inside the loop”.
- AQA 8525 specification
- 3.1.3 (searching algorithms: linear and binary search).
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.
Pupils need computers for the main task.
Also sold in the Compression, Networks and Searching unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
Choose your school's Paper 1 language when you buy: C#, Python or VB.NET. You get that language's files: every program, code example, worked answer and programming task is written in it, and lessons with no code are the same in all three. Algorithms are also shown in AQA pseudo-code, as in the exam.
An independent resource written for AQA GCSE Computer Science (8525). It is not endorsed by AQA.
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
- Your choice of Paper 1 language: C#, Python or VB.NET
More for GCSE Computer Science (AQA)
See allPupils learn to explain what data compression is and why it is used, and represent data as run length encoding frequency/data pairs.
Pupils learn to complete trace tables for algorithms in AQA pseudo-code, flowcharts and the class's language, and state an algorithm's purpose.
Pupils learn to explain how Huffman coding compresses data and read characters' codes from a Huffman tree.
Written for the specifications named. Not endorsed by or affiliated with any exam board.