Implement trees and tries for prefix search
8 steps · about 4 h 45 min · Intermediate
- Learn the vocabulary and invariants of binary trees (guide, Open Data Structures, 40 min)
Parent, child, depth and traversal relationships form the basis of every later operation.
- Implement ordered search and insertion (guide, Open Data Structures, 45 min)
Trace the ordering invariant and see why tree height controls runtime.
- Test traversals and edge cases (guide, Open Data Structures, 30 min)
Exercises reveal whether empty trees, duplicate keys and degenerate shapes are handled consistently.
- See how balancing changes expected cost (guide, Open Data Structures, 40 min)
An unbalanced search tree can become a list, while balancing keeps paths short.
- Search by bits with a binary trie (guide, Open Data Structures, 40 min)
A trie follows key symbols rather than comparing complete keys at each node.
- Understand faster trie navigation (guide, Open Data Structures, 35 min)
X-fast tries show how prefix structure and hashing can cooperate for predecessor search.
- Compare with a dependency-graph structure (reference, Python Software Foundation, 25 min)
A graph representation is the better fit when the application needs dependency order rather than prefix lookup.
- Lock invariants in with focused tests (guide, Python Software Foundation, 30 min)
Test insert, find, prefix results, duplicates and empty inputs against a simple reference model.