01Chapter 1: From Unrooted Graph to Rooted TreeTree problems usually arrive as an edge list with no direction. Dynamic programming on trees needs a direction. You pick a root, give every node a parent, and solve each subtree from the answers of its children.1 min read
02Chapter 2: Warm-up: Subtree Sizes and SumsThis chapter assumes you know array DP, adjacency lists, and DFS. It also assumes you can root a tree and walk its pre-order in reverse, so that every child is finished before its parent. Each problem below uses that same loop. Only the state each node stores changes.2 min read
03Chapter 3: Counting Colorings and Selections Modulo a PrimeThis chapter assumes you know the earlier chapters' root_tree helper and the take/skip states, and that you are comfortable with Big-O analysis. It covers counting with modular arithmetic, rerooting, tree knapsack, and small-to-large merging.2 min read