Open the editor

Computer science · High school

Linear Search Slides

Free animated slides, ready to teach: 6 slides where every step appears on a click and the diagrams move. Play them right here, present them full screen, or copy them into your account to edit.

A real Tracé deck playing in your browser. No account needed.

What the lesson covers

A linear search checks the items of a list one by one until it finds the target or reaches the end. Students watch a pointer step along a list, count comparisons in the best and worst case and see when a binary search would be faster.

The slides, one by one

1 Linear search

Check every item in turn

How do you find one name in an unsorted list?

2 Compare each item with the target

3 The worst case checks every item

\textsf{Best: 1 check; worst: }n\textsf{ checks}
\textsf{Average: about }n/2

4 Searching a list

Search [7, 3, 9, 4, 12, 5] for 4, then for 8. Count the comparisons each time.

→ Compare from the start until found or the list ends

7 \ne 4,\ 3 \ne 4,\ 9 \ne 4,\ 4 = 4

4 found after 4 comparisons

\text{8: all 6 items checked}
\text{8 not found: return } -1

4 is at index 3 (4 comparisons); 8 is missing (6 comparisons)

5 Quick check

A linear search on 500 items. The most comparisons it can need is…

  • 500
  • 250
  • 9
  • 1
Show the answer

500

If the target is last or missing, every one of the 500 items is checked.

6 What to remember

Check items one by one

Works on unsorted data

\textsf{Worst case }n\textsf{, average about }n/2

Binary search is faster on sorted data

Challenge: When might a linear search be the better choice even for a sorted list?

Every slide is built click by click: text, formulas and pictures come in one step at a time, so the class follows the reasoning instead of reading ahead. Graphs with sliders can be dragged live while you present.

Make your own version with AIChange the level, the numbers or the language: type the topic and get a new deck that moves in about 30 seconds. Free, no account needed.

Questions teachers ask

How many comparisons does a linear search make?

In the worst case, when the item is last or missing, it checks all n items. On average it checks about half of them. It works on unsorted lists, unlike binary search, which needs only about log₂ n checks on a sorted list.

Are these slides really free?

Yes. Watch them on this page or present them full screen with no account. Making your own copy to edit is free too.

Can I change the slides before my lesson?

Yes. Press "Make my own copy" and the deck becomes one of your projects in the Tracé editor, where you can change the text, the numbers, the colours or the order of the clicks.

Do they work on a classroom projector or an interactive whiteboard?

Yes. They run in the browser on any laptop, so anything that shows your screen works. Press the right arrow or click to go to the next step.