1 / 8
Programming · Grade 11 · Chapter 8

Algorithms Basics

Searching and sorting — the building blocks of efficient code.

Here's a problem

Searching a Million Names

Finding one name in a list of 10 names is quick, even one by one. But what about a list of a million names? Checking one at a time would take forever. There must be smarter approaches.

Discuss before revealing: If the list were sorted alphabetically, how might you search faster than checking one at a time?
Today's tool

Search and Sort Algorithms

Linear search checks items one by one. Binary search, on sorted data, repeatedly cuts the search space in half — dramatically faster for large datasets. Sorting algorithms organize data to make later searches efficient.

How it works

Linear vs Binary Search

Let's build it together

Implement a Search Algorithm

We'll implement a simple linear search and a binary search, comparing their speed conceptually.

Activity: Live-code both a linear search and binary search function on a sorted list. Discuss how many steps each takes on a large dataset.
Quick check

Which search method is faster on sorted data?

ALinear search
BBinary search
BThey're the same speed
DNeither works on sorted data
Click to reveal answer
Let's discuss

Where might algorithm efficiency matter in your capstone?

If your project handles a lot of data, why might choosing the right algorithm actually matter for performance?

Before you go

Today we learned...

Smart algorithms scale far better than brute-force approaches. Next week: working with real data formats!