Data structures and algorithms lesson plan
The ideas every programmer is asked about, built and measured on an Uno: big O, linked lists, stacks and queues, hash maps, sorting and binary search. Ends with a leaderboard that needs them all.
Objectives and materials
By the end, students can
- Arrays, big O, and lists made from a fixed pool of nodes.
- Stacks, queues and a hash map: limits that make things fast.
- Three sorts raced and counted, then binary search and its off-by-one.
- A leaderboard for a reaction game, built from the whole course.
Materials for the whole unit
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
What things cost
Arrays, big O, and lists made from a fixed pool of nodes.
| Lesson | Time | What students do |
|---|---|---|
| Arrays and big OOne block of 64 ints: an index lookup that costs one step, a scan that costs up to n, a pair check that costs n squared over two, and a table that shows each cost as n doubles. | 50 min |
|
| Linked listsNodes joined by pointers, taken from a fixed pool of 16 so nothing can fragment: add at the head, insert and delete in the middle, run the pool dry, and fix a reverse that leaks. | 50 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "Linked lists" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Fix the reverse".
Structures with rules
Stacks, queues and a hash map: limits that make things fast.
| Lesson | Time | What students do |
|---|---|---|
| Stacks and queuesAn array stack that matches brackets and undoes a running total, and a ring-buffer queue of lamp tasks fed by the serial monitor and the button. Then a stack that overflows, and the fix. | 50 min |
|
| Hash mapsAn 8 slot open-addressing table: a hash function turns a name into a home slot, collisions probe onward, tombstones keep chains whole, the load factor lights a lamp, and a better hash spreads the names out. | 45 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "Hash maps" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A better hash".
Put it in order, find it fast
Three sorts raced and counted, then binary search and its off-by-one.
| Lesson | Time | What students do |
|---|---|---|
| SortingBubble, insertion and quick sort on the same 16 numbers with every comparison and swap counted, best and worst cases, stability shown with tags, a race to 64, and an early exit that makes bubble sort smart. | 50 min |
|
| Searching and binary searchLinear against binary search on 100 sorted numbers with comparisons counted, a slow-motion search on the lamps, a guessing game in ten tries, and an off-by-one found by a self-test. | 50 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "Searching and binary search" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Fix the off-by-one".
Boss
A leaderboard for a reaction game, built from the whole course.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a leaderboardA reaction game and its leaderboard built from the course: players in a hash map, a ranking kept sorted by one insertion pass, binary search for where a score would land, and a stable rule for ties. | 60 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "Boss: a leaderboard" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.