🌳 Algorithms & Data Structures
The patterns that make code fast: hashing, sorting, recursion, complexity.
5 concepts
1
Big-O complexity
How runtime grows with input size. O(1) constant, O(n) linear, O(n²) quadratic, O(log n) logarithmic.
›
2
Hash tables (dicts)
O(1) average insert/lookup/delete. The workhorse of fast Python code.
›
3
Sorting
Python's sorted() uses Timsort (O(n log n)). Stable, fast, built-in.
›
4
Recursion
A function that calls itself. Needs a base case to terminate.
›
5
Caching & memoization
Store expensive results so you don't recompute. functools.lru_cache is the easy button.
›