Goal: “The tree that bends in the wind does not break.” — This week we bend our brains around trees, heaps, and binary search while leveling up Python with OOP and decorators.
Topics
| Day | Track | Focus | Topics |
|---|---|---|---|
| Mon | A — DSA | Queues, Heaps & Trees | Queues and Deques · Priority Queues and Heaps · Design Problems · Binary Trees |
| Tue | B — Python | Closures & Generators | Closures and nonlocal · Decorators · Generators and Iterators |
| Wed | A — DSA | BSTs & Binary Search | Binary Search Trees · Binary Search · Tree Construction and Serialization · Lowest Common Ancestor |
| Thu | B — Python | OOP Foundations | Built-in Functions · Classes and Objects · Inheritance and MRO · Dunder Methods |
| Fri | B — Python | OOP Advanced | @staticmethod vs @classmethod · Property Decorators · Abstract Classes and Interfaces · Dataclasses |
Key Concepts
- Binary search is everywhere — not just sorted arrays. The “binary search on answer” pattern lets us solve problems like “minimum capacity to ship packages” by searching the answer space.
- Trees are recursive structures, so tree problems are naturally recursive. If we can solve for one node assuming children are solved, we’re golden.
- Heaps give us O(log n) insert and O(1) min/max access — perfect for “top K” and streaming problems.
- Python decorators are syntactic sugar for higher-order functions.
@decoratorabove a function is the same asfunc = decorator(func). - MRO (Method Resolution Order) determines which parent method Python calls in diamond inheritance — it uses the C3 linearization algorithm.
- Dunder methods (
__init__,__repr__,__eq__, etc.) let us customize how Python objects behave with operators and built-in functions.
Practice
- Implement a min-heap from scratch (insert, extract-min, heapify)
- Solve 2 binary search variants (e.g., search rotated array, find first/last occurrence)
- Write a Python decorator that logs function calls with arguments and return values
- Create a class hierarchy with an abstract base class — e.g.,
ShapewithCircleandRectanglesubclasses
~19 topics · ~2 hrs/day · Dual-track: DSA trees + Python OOP