Skip to content
GKgkml.dev
← All learning tracks

Learn DSA in Python

10 lessons · ~95 minutes of reading

Most people learn data structures as a catalogue — here is a stack, here is a heap — and then cannot tell which one a problem wants. That is the wrong order. A data structure is a set of trade-offs, and you pick one by knowing which operation has to be fast.

This track builds that judgement. It starts with how to reason about cost at all, then walks the structures in the order they actually build on each other, and finishes with the two techniques — graphs and dynamic programming — that most interview failures come down to.

Every lesson ends with the questions it prepares you for, so you can read one topic and immediately test whether it stuck.

Assumes: You can write Python functions, loops and classes. No prior algorithms background is assumed.

The lessons

  1. 1

    Complexity: how to reason about cost

    Read an algorithm and state its time and space cost without running it — and know when big-O is lying to you.

    9 minPractise: Easy
  2. 2

    Python's containers and what they really cost

    Know which operation on a list, dict, set or deque is fast — and stop writing accidental O(n²) loops.

    10 minPractise: Easy
  3. 3

    Arrays, two pointers and sliding windows

    Turn nested-loop scans into single passes when the data is sorted or the range is contiguous.

    9 minPractise: Medium
  4. 4

    Hashing: trading memory for time

    Understand what a hash table does under the hood, and recognise the problems it collapses.

    7 minPractise: Easy
  5. 5

    Recursion and backtracking

    Write recursive solutions confidently, and turn 'try every possibility' into a pruned search.

    10 minPractise: Medium
  6. 6

    Sorting and binary search

    Know what Python's sort guarantees, and learn to binary search the answer rather than the array.

    9 minPractise: Medium
  7. 7

    Linked lists, stacks and queues

    Pointer manipulation without off-by-one bugs, and the two structures that model order.

    8 minPractise: Medium
  8. 8

    Trees, BSTs and heaps

    Traverse trees in the right order, use the BST invariant properly, and know when a heap beats sorting.

    10 minPractise: Medium
  9. 9

    Graphs: traversal, ordering and connectivity

    Recognise a graph problem in disguise, pick BFS or DFS deliberately, and handle cycles and dependencies.

    11 minPractise: Hard
  10. 10

    Dynamic programming without the fear

    Define a state, write the transition, and choose top-down or bottom-up deliberately.

    12 minPractise: Hard

What the practice bank covers

The lessons above are written against this syllabus, so anything in the question bank has been taught before you meet it.

  • Asymptotics: big-O, amortised, best/avg/worst
  • Python containers: list, tuple, dict, set, deque, heapq
  • Strings, slicing, immutability, interning
  • Two pointers, sliding window, prefix sums
  • Sorting & searching, binary search on answer
  • Stacks, queues, monotonic structures
  • Linked lists, fast/slow pointers
  • Trees: traversal, BST, balancing, tries
  • Heaps, top-k, median maintenance
  • Graphs: BFS/DFS, topological sort, Dijkstra, union-find
  • Dynamic programming: 1-D, 2-D, knapsack, LIS, intervals
  • Backtracking, greedy, bit manipulation