Open the editor

Computer science · High school

Binary 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

Binary search finds an item in a sorted list by checking the middle and throwing away the half that cannot hold it. Students trace a search step by step, read the code and see why a million items need only 20 checks.

The slides, one by one

1 Binary search

Halve the list, again and again

Can you find any number from 1 to 1,000 in 10 guesses?

2 Check the middle, then discard half

Looking for 23

16 < 23: keep the right half

56 > 23: keep the left part; found!

3 Low and high close in on the target

mid = (low + high) // 2

Found 23 in 3 checks, not 6

4 Steps for a million items

A sorted list has 1,000,000 items. What is the most comparisons binary search needs?

→ Find the smallest k with 2ᵏ ≥ n

2^{19} = 524\,288 < 10^6
2^{20} = 1\,048\,576 \ge 10^6
k = 20

At most 20 comparisons

5 Quick check

At most how many comparisons does binary search need for 1,000 sorted items?

  • 500
  • 10
  • 1000
  • 32
Show the answer

10

2¹⁰ = 1,024 ≥ 1,000, so 10 halvings are enough.

6 What to remember

Only works on a sorted list

Check the middle, discard half

\textsf{About }\log_2 n\textsf{ steps}
O(\log n)\textsf{: fast for huge lists}

Challenge: Why does binary search fail on an unsorted 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 steps does binary search take?

At most about log₂ n comparisons, because each step halves the list. A sorted list of 1,000 items needs at most 10 checks (2¹⁰ = 1,024) and a million items about 20.

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.