Grades 4–7 · STEM & Computer Science
How do you teach linear vs binary search in Grades 4–7?
Short answer: Give students a short sorted list of book numbers and a target. They trace a linear search from the start and a binary search that checks the middle remaining number each time, counting comparisons for both. Then show an unsorted list and ask what must happen before binary search can work.
- Grades4–7
- FormatUnplugged, paper traces
- ConceptsLinear search, binary search, comparisons, preconditions
- Includes42-page PDF, 16 slides, 5 worksheets, 5 answer keys
Search algorithms are one of the clearest ways to show younger students that how you solve a problem matters, not just whether you solve it. Every child has looked for something by checking items one by one. Fewer have noticed that a sorted list allows a much faster strategy.
Build a Library Search Algorithm uses a small library scenario: book ID numbers on a sorted shelf list. Students trace two methods with paper and pencil, count how many comparisons each takes, and discover the condition that makes binary search possible. No computers are needed, and the traces themselves become the evidence.
Units for this topic
Build a Library Search Algorithm
The lead unit: students compare linear and binary search on a sorted list and explain the sorting precondition.
Unplugged Robot Debugging Cards
Unplugged debugging of grid commands for Grades 2–5, building the same tracing habit.
Spreadsheet Skills for Classroom Data
Students clean a dataset before charting it, another lesson in preparing input before running a method.
Sensor Calibration with a Paper Microcontroller
Students write pseudocode for a sensor correction and test it, extending algorithmic thinking.
Repair a Broken Web Form
Students specify how a web form should behave when users make errors, applying precise rule writing.
Two ways to find book 55
The starting case in Build a Library Search Algorithm lists sorted IDs: 11, 19, 22, 38, 47, 55, 62. The target is 55. A linear search checks each number from the left and finds 55 on the sixth comparison.
Binary search starts in the middle. The middle of seven numbers is 38. Since 55 is larger, every number from 38 down can be skipped. The remaining list is 47, 55, 62, and its middle is 55, found on the second comparison. Students write both traces side by side and count.
- Linear search: check in order until found or the list ends
- Binary search: check the middle remaining item, then discard half
- Count comparisons for each trace
Why binary search can skip half
The learning-check item asks why binary search can skip the lower half after comparing 55 with the midpoint 38. The answer depends on the list being sorted: every number left of 38 is smaller than 38, so none of them can be 55. Students who can explain this understand the algorithm, not just the steps.
The second context uses a new list, 5, 11, 14, 21, 30, 33, 40, and asks students to trace binary search for 11. A third case searches the same list for 27, a number that is not there. Students trace until no items remain and record that the target is absent, which teaches that an algorithm must also know when to stop.
A follow-up task changes the target in the first list to 54. Binary search checks 38, then 55, then 47, and runs out of items. Three comparisons are enough to prove that 54 is not on the shelf list, while a linear search would have checked every number up to 55 before it could stop.
The precondition: sort first
The transfer challenge shows the list as 5, 30, 14, 21, 11, 33, 40. What must happen before binary search? The list must be sorted. Students try a binary search on the unsorted list to see it fail, then explain the precondition in their own words.
This is a good place to connect with other debugging work. Unplugged Robot Debugging Cards has younger students trace grid commands to find the first invalid move, and Spreadsheet Skills for Classroom Data has students clean data before analyzing it, another case of preparing input before running a method.
Ask students when a linear search would still be the better choice. A shelf of three books, or a list that changes too often to keep sorted, are reasonable answers. The goal is judgment about methods, not a rule that one is always faster.
Inside the unit
The unit includes a 42-page teaching PDF with four 90-minute double lessons, an entry diagnosis, differentiation, teacher background, five learner inputs with mini-checks, five ready-to-copy worksheets, five answer keys, support and extension cards, and a 20-point learning check with model responses and a 100-point scoring sheet. Sixteen slides with teacher notes model the traces step by step.
A five-step sequence
-
Act out a linear search
Write the seven book IDs on cards in order. A student flips cards one by one until finding 55 while the class counts comparisons.
-
Act out a binary search
Reset the cards. The student checks the middle card, 38, discards the lower half, then checks the middle of what remains.
-
Write both traces
Students record each comparison in a table for both methods and compare the totals.
-
Search for a missing number
Trace a binary search for 27 in the second list until no items remain, and record how the algorithm knows to stop.
-
Test the precondition
Shuffle the list and try binary search again. Students explain why it fails and what must be done first.
Common mix-ups and what to try
Binary search works on any list.
It only works on a sorted list. Without order, discarding half of the list could throw away the target.
A search that does not find the target has failed.
Correctly reporting that a target is absent is a valid result. Students trace the search for 27 to see how the algorithm ends.
The faster algorithm is always better.
Binary search needs sorted data. For a short or unsorted list, a linear search may be the sensible choice.
More STEM & Computer Science units
Related teaching guides
Frequently asked questions
Do students need computers?
No. Everything runs on paper or with number cards. Classes that code can implement the searches afterward.
Is this too advanced for Grade 4?
The lists have seven numbers, so the traces stay short. Support cards help younger students find the middle item.
How do students show understanding?
Through written traces with comparison counts and an explanation of why binary search can skip half the list.
What vocabulary does the unit introduce?
Algorithm, trace, comparison, midpoint, sorted and precondition, all introduced through the library scenario.
How is learning assessed?
The 20-point learning check asks students to trace searches and justify each step. Model responses and a 100-point scoring sheet support marking.
What if it does not match my computer science standards?
Every resource is built around the curriculum you teach – and if something doesn't fit your standards, the TeachLessons Guarantee applies: we adapt it for you.
Ready for your next lesson?
Get Build a Library Search Algorithm and let your class discover why sorting changes everything.
View Build a Library Search AlgorithmInstant digital download. Every resource is built around the curriculum you teach – and if something doesn't fit your standards, the TeachLessons Guarantee applies: we adapt it for you.

