GCSE
Lesson 6 Comparing searching algorithms
During this lesson, learners will compare the features of linear search and binary search and the suitability of each algorithm in different contexts. They will also interpret the code of both algorithms in Python, as well as analyse the efficiency of two implementations of the linear search algorithm. There are demo versions of linear search and binary search that output the steps of each comparison which are linked in the “You may also need” section below, where you will also find the commented code used in the slides and worksheets. Learners will start by analysing the factors that can affect the performance of linear and binary search: whether the data is ordered, the number of comparisons, and the simplicity of the algorithm. Next, they will perform a linear and binary search on a sample of data so they can visually compare the number of comparisons made when using each algorithm. The slides for the final two activities demonstrate and explain a step-by-step Python implementation for each searching algorithm. The slides for both the linear search and binary search in Python build up from the inside out, focussing first on how one comparison is made before adding the functionality to repeat this process. Each of the Python activities culminates with a worksheet that gets learners to further explore and understand the demoed code with questions and tracing the algorithm with a given set of data. Furthermore, a more efficient version of linear search is presented in a worksheet so learners can compare the efficiency of these two implementations.
Learning objectives
- Compare the features of linear and binary search and decide which is most suitable in a given context
- Interpret the code for linear search and binary search
- Trace code for both searching algorithms with input data
Package contents
- Lesson plans
- Learning graphs
- Unit overviews
- Activities
Not registered yet?
Create an account and get access to over 500 hours of free teaching resources.
GCSE revision
A comprehensive range of content and helpful practice questions are also available for this topic.