- Make sure the list is sorted.
- Set the low pointer to the first position and the high pointer to the last position.
- Find the midpoint: (low + high) DIV 2. DIV means divide and drop any remainder.
- Compare the middle item with the target.
- Equal: the target is found. Stop.
- Target is larger: it must be in the right half, so set low to mid + 1.
- Target is smaller: it must be in the left half, so set high to mid - 1.
- Repeat from step 3. If low becomes greater than high, the target is not in the list.
This study notes covers Deep Dive: The Steps of Binary Search within Binary Search for GCSE Computer Science. Revise Binary Search in 3.1 Fundamentals of Algorithms for GCSE Computer Science with 15 exam-style questions and 10 flashcards. This is a high-frequency topic, so it is worth revising until the explanation feels precise and repeatable. It is section 3 of 8 in this topic. Use this study notes to connect the idea to the wider topic before moving on to questions and flashcards.
Practice questions for Binary Search
Which of the following is a requirement before binary search can be used?
Describe how a binary search algorithm finds a target value in a sorted list.