Stage 4
Stage 4: DSA in Python
Goal: Learn to measure and choose the right data structure and algorithm, and get fast enough at spotting patterns to solve new coding problems on your own. Time: about 2 weeks: one or two lesson sections a day (30–60 minutes), plus 2–3 practice problems a day · Level: you have finished Stage 3
Parts in this stage
One part, twenty topics, done in the order below. Each topic builds on the one before: arrays make hashing's wins measurable, prefix sums set up two pointers, sorting is what makes binary search and intervals possible, BFS is the seed of topological sort and Dijkstra, and so on.
| Part | Topic | You will build | Time |
|---|---|---|---|
| 17 | Data structures and algorithms in Python | Undo button (stack), trending posts (heap), delivery route (graph), and seventeen more small real-world programs | ~12 h |
How the part is organised
part-17-dsa-in-python/
├── README.md ← 1. read the lesson (20 numbered sections, in order)
├── examples/ ← 2. run the example programs
├── exercises.md ← 3. solve the practice questions yourself
└── solutions/ ← 4. only then compare with the solution
How to study this stage
- Read one numbered section of
part-17-dsa-in-python/README.mdat a time — not the whole file in one sitting. Twenty sections: one or two a day fits the two weeks. - Run the matching example in
examples/, then change the input data and run it again. - Solve 2–3 problems a day on the pattern you just read. Each section of the part ends with a Practice on LeetCode block: the visible "start here" lists (88 problems across the twenty patterns, gentler ones first) are this stage's two-week plan, and the folded core and stretch lists behind them (another ~250 problems) are the pool to keep drawing from once the two weeks are over — the daily habit shouldn't stop when the stage does. This drip matters more than reading speed: DSA is a skill you build with your hands, not a fact you memorise.
- Solve
exercises.mdin order, one per topic. - Check your answer against
solutions/only after you have tried. - Tick the ✅ checklist at the end of the part.
💡 Stuck on a pattern? Re-read that section's everyday analogy first (undo stacks, queue at a counter, binary search in a phone book). The code is easier once the picture is clear.
How to run the code
python3 stage-4-dsa/part-17-dsa-in-python/examples/06_stack_queue_deque.py
On Windows, use python (or py) instead of python3. Everything in this stage uses only the standard library (collections, heapq, bisect, timeit) — nothing to install.
Stage 4 checklist
- Part 17 read, section by section, in the fixed order (Big-O → arrays/strings → hashing → prefix sums → two pointers/sliding window → stack/queue → sorting → binary search → linked list → recursion/backtracking → trees → heaps → greedy → intervals → tries → graphs → topological sort/union-find → shortest paths → dynamic programming → bits)
- Every example in
examples/run and tinkered with - Every exercise in
exercises.mdattempted before checkingsolutions/ - At least 50 practice problems solved (2–3 a day), easy before medium
- Comfortable explaining the Big-O of each data structure's main operations without looking it up
Next: 🚀 Stage 5: Specialization (pick one track: web backend, data analytics, ML/AI, or automation)