Ch 10 · Mini-Projects & Practice · Data Structures & Algorithms
Topic 10 of 10 in Data Structures & Algorithms — Foundations — 3 lessons.
Project: Bracket Validator
Use a stack (last in, first out) to build a tiny tool that checks whether code brackets are balanced — the same check your editor runs as you type.
Project: Word Frequency Counter
Count how often each word appears in a sentence — a one-line job for a dict (and the seed of how search engines rank pages).
Project: Pair Finder (Two-Sum)
A shop has a list of prices and you have a gift card worth exactly 43. Which two items add up to 43? The slow way tries every possible pair, which means a loop inside a loop. The fast way walks the list once. For each price it works out the partner it would need (43 minus the price) and asks a set whether it has already seen that partner. Both functions also count how many checks they make. Here the matching pair, 3 and 40, sits at the very end of the list, which is the worst case: the slow version checks all 28 pairs, while the fast version needs only 8 checks. With a thousand prices the gap grows to about half a million checks against one thousand.
All topics in Data Structures & Algorithms Beginner
- Thinking Like a Computer Scientist
- Arrays & Lists — The Workhorse
- Stacks — Last In, First Out
- Queues — First In, First Out
- Linked Lists — Nodes on a Chain
- Searching — Finding the Needle
- Sorting — Putting Things in Order
- Recursion — Functions That Call Themselves
- Hash Tables — Instant Lookups
- Mini-Projects & Practice