Step-by-Step Lesson

Learn: Binary Search - How It Works

OCR GCSE J277 Computer Science specification

Ready to start this lesson?

Sign in to track your progress. 15 steps including 7 interactive questions.

Sign In to Start Learning
15 Steps7 Questions

Students also studied

Browse all

Steps in this lesson (15)

1
Text

Welcome!Welcome back! You've already learned about how linear search works and how to trace it through a data set. Today, we'll build on that understanding and explore binary search, a faster way to find data in a sorted list.Get ready for an interactive and fun session!

2
Text

What is Binary Search?Binary search is an algorithm used to efficiently find a target value in a sorted list. Instead of checking one item at a time like linear search, binary search splits the list in half and focuses on the part where the target could be. This makes it much faster!

3
Text

How Does Binary Search Work?Binary search works by dividing the list into halves repeatedly. It checks the middle item of the list. If the target value matches, the search stops. If not, it decides whether the target is in the lower half or upper half, then repeats the process until the value is found or the list is empty.

4
Multiple ChoiceInteractive

What is the key requirement for a binary search to work?

Start the lesson to answer this multiple choice question

5
Text

Steps of Binary SearchHere are the steps for binary search:Start with the entire sorted list.Find the middle item.Compare the middle item to the target value.If it matches, stop. If not, decide whether the target is in the lower or upper half.Repeat the process with the smaller half until the target is found or the list is empty.

6
Fill in the BlankInteractive

Binary search works by repeatedly checking the {{blank0}} element of a {{blank1}} list.

Start the lesson to answer this fill in the blank question

7
Text

Why is Binary Search Faster?In linear search, you might have to check every item in the list one-by-one, which takes a long time for large lists. Binary search halves the search space with every step, making it much faster. For example, a list with 1,000 items can be searched in about 10 steps!

8
Text

Tracing Binary SearchLet's go through an example. Imagine you have a sorted list: [1, 3, 5, 7, 9, 11, 13, 15]. You want to find 9. First, check the middle element (7). Is it 9? No. Is 9 larger or smaller than 7? Larger. So now only the upper half of the list needs to be checked. Repeat the process!

9
Multi-SelectInteractive

Which of the following are true about binary search? (Select all that apply)

Start the lesson to answer this multi-select question

10
Text

Review Time!Great work! You've learned all about binary search, how it works, why it's faster, and how to trace it step-by-step. Let's test your understanding with a few final questions.

11
Multiple ChoiceInteractive

What is the first step in binary search?

Start the lesson to answer this multiple choice question

12
MatchingInteractive

Match the items on the left with their correct pairs on the right

Start the lesson to answer this matching question

13
Fill in the BlankInteractive

Binary search halves the {{blank0}} space at each step, making it {{blank1}} than linear search.

Start the lesson to answer this fill in the blank question

14
Math EquationInteractive

Match the items on the left with their correct pairs on the right

Start the lesson to answer this math equation question

15
Text

Congratulations!You've mastered binary search. Keep practising tracing it on different data sets to build confidence. Well done!

Genie

Want to Learn More?

Get personalised lessons, quizzes, and instant feedback from your AI tutor.

Explore More Topics