Back to Searching Algorithms

Oak National Academy

Lessons written by expert teachers in England, each with slides, a video and quizzes.

Their topic:
Searching and sorting algorithms
For your topic:
Searching Algorithms · Computer Science - 9210

Use these lessons alongside our lesson note, which covers your syllabus in full.

What this covers in your syllabus

3 lessons from Oak National Academy

Lesson 1 of 3 · GCSE level, ages 14 to 16

Binary search

By the end: I can identify when a binary search can be used and perform its steps on a set of data.

Key learning points

  1. Binary search is an algorithm which can be used to search for an item in a sorted data set.
  2. It discards half of the remaining data with each comparison and repeats the process until the item is found.
  3. On average, a binary search can locate an item in a list in less time than a linear search.
  4. If the data you have is unordered, you must either use a linear search algorithm or sort the data first.

Keywords

binary search
an algorithm to search for an item in a sorted data set — it discards half of the remaining data with each comparison and repeats the process until the item is found or until the data set is exhausted
ordered list
a list of items where the values are in either ascending or descending order

A common mistake

Mistake: A binary search can be performed on any data.

In fact: A binary search can only be performed on an ordered list as it finds the expected position of the search term based on a selected mid-point in the data.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What type of list is required for a binary search to work?
What happens if the data is unordered and you want to perform a binary search?
Why is binary search typically faster than linear search for large data sets?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 2 of 3 · GCSE level, ages 14 to 16

Comparing searching algorithms

By the end: I can compare and contrast linear and binary search and trace the code for both searching algorithms.

Key learning points

  1. The searching algorithm you use will depend on the data and context you are using.
  2. Coding a binary search is more complex than a linear search.
  3. Tracing code for searching algorithms by completing a trace table can help you check how efficient the algorithm is.

Keywords

algorithm
a set of step-by-step instructions to solve a problem
trace table
a tool used to track the values of variables and the flow of execution in an algorithm or program, step by step

A common mistake

Mistake: A linear search algorithm and binary search algorithm are equally complex to write.

In fact: Binary search algorithms are more complex to write due to the different paths that the algorithm can take rather than stepping through the search data in order.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is a trace table used for?
Which searching algorithm is more complex to write?
Which of these is true about linear search?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

Lesson 3 of 3 · GCSE level, ages 14 to 16

Linear search

By the end: I can explain why computers need to search data and perform a linear search to find the position of an item in a list.

Key learning points

  1. Computers can quickly search through large amounts of data to find what is needed.
  2. Linear search is an algorithm that involves checking each item in a list of data one at a time.
  3. Linear search is able to find items that are in any order.
  4. The best-case scenario of a linear search is when the search item is the very first one in the list.
  5. The worst-case scenario is when the item you are looking for is the very last one in the list or it isn’t in the list.

Keywords

linear search
an algorithm that searches for an item in a list of items by systematically examining each item, one after another
best-case
this scenario occurs when the item you are looking for results in the smallest possible number of steps
worst-case
this scenario takes place when the item you are looking for results in the greatest possible number of steps

A common mistake

Mistake: A linear search can only be used on lists or sequences of numbers.

In fact: A linear search can be used on lots of different types of data, including strings.

Check what you learned

From Oak National Academy's exit quiz. Choose every answer that is right.

What is a linear search?
What type of data can a linear search be used on?
What happens if the item being searched for is not in the list?
What is the main advantage of a linear search?

A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0. Read the licence

The wording comes from each publisher. The layout and the links to your syllabus are ours.