Skip to content
All paths
Beginner → IntermediateFoundations

Data Structures & Algorithms

A full, language-neutral course in data structures and algorithms with Python examples. Every topic pairs theory and complexity analysis with your own implementation and a set of problems, from arrays and hashing through trees, graphs and dynamic programming to segment trees, ending with a personal algorithms library and timed problem sets.

What you will be able to do

  • Analyse the time and space complexity of any algorithm you write or read
  • Implement core data structures from scratch and know their trade-offs
  • Apply sorting, searching, tree and graph algorithms to unfamiliar problems
  • Recognise greedy, dynamic programming and backtracking problems and derive solutions
  • Solve medium-level coding problems within a timed session and explain them clearly

Roadmap

Bar length shows each module's share of study time.

  1. 1

    Complexity analysis & math basics

    The language for comparing algorithms, plus the math it rests on.

    14h5 topics
    Not started
    Show topics
  2. 2

    Arrays & strings

    Contiguous memory, resizing and the most common interview data type.

    12h4 topics
    Not started
    Show topics
    • Explain why array indexing is O(1) and insertion in the middle is O(n).

      • Compute element addresses from the index
      • Insert and delete by shifting elements
      • Explain cache locality benefits
      • Work with 2D arrays as row-major
    • Implement a growable array and prove append is amortised O(1).

      • Track size versus capacity
      • Grow by doubling and copy
      • Implement append, pop, get and set
      • Prove amortised O(1) append
    • Manipulate strings efficiently and solve anagram, palindrome and parsing problems.

      • Explain string immutability and its costs
      • Build strings with join, not +=
      • Count characters with arrays or Counter
      • Solve palindrome and anagram problems
      • Parse tokens from a string
    • Answer range-sum queries in O(1) and rearrange arrays in place without extra memory.

      • Build 1D prefix sum arrays
      • Answer range queries in constant time
      • Use 2D prefix sums for submatrices
      • Reverse and rotate arrays in place
      • Partition an array in one pass
  3. 3

    Linked lists, stacks, queues & deques

    Pointer-based sequences and the LIFO/FIFO structures built on them.

    14h 30m5 topics
    Not started
    Show topics
    • Implement a singly linked list and reverse, merge and split lists with pointer manipulation.

      • Implement node and list classes
      • Insert and delete at head and tail
      • Reverse a list iteratively and recursively
      • Use a dummy head node
      • Merge two sorted lists
    • Use doubly linked and circular lists and detect cycles with fast and slow pointers.

      • Implement a doubly linked list with sentinels
      • Remove a node in O(1)
      • Detect cycles with Floyd's algorithm
      • Find the middle with fast and slow pointers
    • Implement a stack and use it for bracket matching, expression evaluation and undo history.

      • Implement a stack on a list
      • Match brackets with a stack
      • Evaluate postfix expressions
      • Replace recursion with an explicit stack
    • Implement a queue with a circular buffer and choose between queue and deque for a problem.

      • Implement a ring buffer queue
      • Explain why list.pop(0) is O(n)
      • Use collections.deque at both ends
      • Build a sliding window maximum with a deque
    • Solve next-greater-element and histogram problems in O(n) with a monotonic stack.

      • Maintain an increasing or decreasing stack
      • Find the next greater element
      • Solve daily temperatures
      • Find the largest rectangle in a histogram
  4. 4

    Hashing

    Constant-time lookup and the collisions that make it interesting.

    10h3 topics
    Not started
    Show topics
    Module resources:VisuAlgo: hash table ↗
  5. 5

    Recursion, sorting & searching

    Think recursively, divide and conquer, then sort and search efficiently.

    19h7 topics
    Not started
    Show topics
    • Write correct recursive functions with clear base cases and trace them on the call stack.

      • Identify base case and recursive case
      • Trace calls on the call stack
      • Draw recursion trees
      • Know Python's recursion limit
      • Convert simple recursion to iteration
    • Split a problem into independent subproblems and combine their answers efficiently.

      • Identify divide, conquer and combine steps
      • Solve maximum subarray with divide and conquer
      • Analyse with recurrences
      • Count inversions during merging
    • Implement the quadratic sorts and explain stability and when insertion sort wins.

      • Implement bubble and selection sort
      • Implement insertion sort
      • Define stable and in-place sorting
      • Explain insertion sort on nearly sorted data
    • Implement merge sort and explain its guaranteed O(n log n) time and O(n) extra space.

      • Split recursively to single elements
      • Merge two sorted halves
      • Analyse the recursion tree
      • Implement a bottom-up variant
    • Implement quicksort with a good pivot strategy and find the k-th element with quickselect.

      • Partition with Lomuto and Hoare schemes
      • Choose random or median-of-three pivots
      • Explain the O(n^2) worst case
      • Find the k-th smallest with quickselect
    • Sort integers in linear time and use Python's sort with keys correctly.

      • Implement counting sort
      • Implement LSD radix sort
      • Explain the comparison sort lower bound
      • Sort with key functions and Timsort
    • Write bug-free binary search and apply it to monotonic answer spaces.

      • Write binary search with clear invariants
      • Find first and last occurrence
      • Search a rotated sorted array
      • Binary search on the answer space
      • Use the bisect module
    Module resources:VisuAlgo: sorting ↗
  6. 6

    Trees, heaps & tries

    Hierarchical structures for ordered data, priorities and prefixes.

    18h 30m6 topics
    Not started
    Show topics
    • Traverse a binary tree in pre-, in-, post- and level order, recursively and iteratively.

      • Learn tree vocabulary: root, leaf, height
      • Implement pre-, in- and post-order
      • Implement level-order with a queue
      • Write iterative traversals with a stack
      • Compute height and diameter
    • Implement BST search, insert and delete and explain why balance matters.

      • Implement search and insert
      • Delete nodes with zero, one, two children
      • Find successor and predecessor
      • Validate a BST
      • Show degeneration into a linked list
    • Explain how rotations keep AVL and red-black trees at O(log n) height.

      • Perform left and right rotations
      • Track AVL balance factors
      • State the red-black tree rules
      • Compare AVL and red-black trade-offs
      • Know where balanced trees appear in libraries
    • Implement an array-based min-heap with sift-up, sift-down and O(n) heapify.

      • Map tree positions to array indexes
      • Implement push with sift-up
      • Implement pop with sift-down
      • Build a heap in O(n)
    • Use heaps for top-k, merging sorted lists and scheduling, and implement heap sort.

      • Use heapq for push and pop
      • Find top-k elements with a size-k heap
      • Merge k sorted lists
      • Track a running median with two heaps
      • Implement heap sort
    • Implement a trie and use it for prefix search and autocomplete.

      • Implement insert and search
      • Answer startsWith prefix queries
      • Collect words for autocomplete
      • Compare tries with hash sets
  7. 7

    Graphs: representations & traversal

    Model relationships and explore them systematically.

    13h 30m5 topics
    Not started
    Show topics
  8. 8

    Shortest paths & minimum spanning trees

    Weighted graph algorithms for routes and cheap networks.

    9h 30m3 topics
    Not started
    Show topics
  9. 9

    Greedy algorithms & dynamic programming

    Optimisation by local choice, or by reusing overlapping subproblems.

    21h 30m6 topics
    Not started
    Show topics
    • Recognise problems with the greedy-choice property and justify a greedy solution.

      • Schedule intervals by earliest end time
      • Merge overlapping intervals
      • Prove greedy with an exchange argument
      • Find counterexamples where greedy fails
      • Solve jump game and gas station
    • Turn a recursive solution into memoised and bottom-up DP and solve classic 1D problems.

      • Spot overlapping subproblems and optimal substructure
      • Memoise with a dict or lru_cache
      • Convert to bottom-up tabulation
      • Solve climbing stairs and house robber
      • Reduce space to O(1)
    • Define 2D states and fill grid and string DP tables in the right order.

      • Count unique grid paths
      • Find minimum path sum
      • Compute edit distance
      • Choose table fill order
      • Reduce a 2D table to one row
    • Solve 0/1 and unbounded knapsack and map subset-sum and coin-change problems onto them.

      • Define the 0/1 knapsack state
      • Iterate capacity backwards for 1D DP
      • Solve unbounded knapsack and coin change
      • Solve subset sum and partition
    • Compute longest increasing and longest common subsequences and reconstruct the answers.

      • Solve LIS in O(n^2) with DP
      • Solve LIS in O(n log n) with patience
      • Solve LCS with a 2D table
      • Reconstruct the subsequence from the table
    • Solve problems over subarrays by iterating interval length, such as burst balloons and matrix chain.

      • Define dp over intervals i to j
      • Iterate by increasing interval length
      • Solve matrix chain multiplication
      • Solve palindromic substring problems
    Module resources:NeetCode roadmap ↗
  10. 10

    Backtracking & bit manipulation

    Systematic search with pruning, and tricks with binary representations.

    9h 30m3 topics
    Not started
    Show topics
    • Generate subsets, permutations and combinations with a choose-explore-unchoose template.

      • Learn the choose, explore, unchoose template
      • Generate all subsets
      • Generate all permutations
      • Generate combinations and combination sums
      • Skip duplicates in sorted input
    • Solve N-Queens, Sudoku and word search efficiently by pruning invalid branches early.

      • Solve N-Queens with column and diagonal sets
      • Solve word search on a grid
      • Write a Sudoku solver
      • Prune branches with constraint checks
    • Use bitwise operators to test, set and count bits and represent sets as bitmasks.

      • Use AND, OR, XOR, NOT and shifts
      • Test, set and clear individual bits
      • Count bits and isolate the lowest bit
      • Find the single number with XOR
      • Enumerate subsets with bitmasks
    Module resources:LeetCode problem set ↗
  11. 11

    Advanced patterns & range structures

    Linear-time array patterns and logarithmic range queries.

    13h4 topics
    Not started
    Show topics
    • Replace nested loops with converging or same-direction pointers on sorted arrays and lists.

      • Use converging pointers on sorted arrays
      • Solve two-sum II and three-sum
      • Remove duplicates in place
      • Solve container with most water
    • Solve substring and subarray problems in O(n) with fixed and variable windows.

      • Use fixed-size windows for averages
      • Grow and shrink variable windows
      • Find the longest substring without repeats
      • Find the minimum window substring
    • Implement a Fenwick tree for prefix sums with point updates in O(log n).

      • Explain the lowbit index trick
      • Implement point update
      • Implement prefix and range queries
      • Count inversions with a Fenwick tree
    • Implement a segment tree for range sum, min or max queries with point updates.

      • Build the tree recursively
      • Answer range queries
      • Apply point updates
      • Generalise to min, max and gcd
      • Understand lazy propagation for range updates
  12. 12

    Capstone: library & timed problem sets

    Consolidate everything into your own tested library and timed practice.

    22h3 topics
    Not started
    Show topics
    • Publish a Python package of your own data structures and algorithms with tests and benchmarks.

      • Implement core structures in one package
      • Write pytest tests including edge cases
      • Benchmark against built-ins with timeit
      • Document complexity for every function
      • Publish the repo with a README
    • Solve mixed-topic medium problems within 30 to 45 minutes each using a repeatable method.

      • Use a clarify, plan, code, test method
      • Solve mixed sets under a timer
      • Explain the approach out loud
      • Log mistakes and pattern misses
      • Revisit failed problems after a week
    • Map any new problem to a known pattern and keep every topic fresh with spaced review.

      • Build a pattern-to-problem cheat sheet
      • Re-solve one problem per pattern
      • Schedule spaced review of weak topics