Graph Theory37 sections · 1633 units
Open in Course

Aggregating Child Values

Sum, max, count patterns

Common aggregation operations:

1.1. Sum: dp[v] = Σ_c in children(v) dp[c]

2.2. Max: dp[v] = max_c in children(v) dp[c]

3.3. Count: dp[v] = |\{c : dp[c] > 0\}|

Pick the operation that matches your problem. Subtree size uses sum. Maximum path uses max. The aggregation function determines how you combine child answers into the parent answer.