KS4 – Algorithms Homework
Lesson 8 – Comparing searching algorithms
Homework
Task . Binary search algorithm
The steps for performing a binary search are written out below but they have
been mixed up. Some of the instructions are also incomplete.
Number the steps from 1-8 so that the instructions are in the correct sequence
and fill in the missing information.
Step Instruction
number
7 Repeat steps __3-6____ until you find the item you are searching
for or there are no more items to check (the range is empty).
4 If the midpoint item is equal to the search item, then
__finish____
2 Maintain a range of items where the search item might be
found. Initially, set the range to be the __whole list____
3 Find the item in the middle of the range (the midpoint item).
5 Otherwise, if the midpoint item is less than than the search
item, change the range to focus on the items after the
midpoint.
1 Take an ordered list of data and an item that is being searched
for (the search item).
6 Otherwise, if the midpoint item is greater than than the search
item, change the range to focus on the items before the
midpoint.
4 Compare the midpoint item to the ____desired item__