Data Structures in Python
Master data structures in Python: Big-O, lists, dicts and sets, deques and heaps, trees and tries, graphs, union-find, LRU caches and interview patterns.
What you'll learn
- Analyse time and space complexity and understand Python's object model, references and copies.
- Use lists, tuples, dataclasses, strings and bytes efficiently, knowing the cost of each operation.
- Apply dicts, sets and the collections module for lookups, counting, grouping and layered data.
- Implement and use stacks, queues, linked lists, heaps, binary trees, BSTs and tries.
- Represent graphs and apply BFS, DFS, Dijkstra, topological sort and union-find to real problems.
- Build caches and custom containers, save memory at scale, and solve problems with common interview patterns.
Syllabus
Foundations: Complexity and Python's Object Model
- Why Data Structures and Big-O Matter
- Python's Object Model: References, Mutability and Copies
- Measuring Time and Memory
Sequences: Lists, Tuples and Strings
- Lists: Python's Dynamic Array
- Tuples, namedtuple and dataclasses
- Strings, Bytes and Efficient Text Building
Hash Tables: dict, set and collections
- Dictionaries: Hash Tables in Practice
- Sets and Frozensets
- Counter, defaultdict, OrderedDict and ChainMap
Stacks, Queues, Linked Lists and Heaps
Trees and Tries
Graphs
Advanced Structures and Memory
- Union-Find (Disjoint Set Union)
- Caches: LRU with OrderedDict and functools
- Memory-Efficient Structures: slots, array, generators and NumPy