Graph Theory37 sections · 1633 units
Open in Course

Think First

(State definition)

Before reading the solution, think:

1.1. What states do you need? For each node u, what decisions affect the answer? (Hint: Does u use an edge to its parent?)

2.2. How do you combine child states? If u does not use edge to parent, what can children do? If u does use it, what happens to one child?

3.3. what is the recurrence? Write dp[u][0] and dp[u][1] in terms of children.

Try to define the states clearly: 'dp[u][00] means.' and 'dp[u][11] means.'. Then write the transitions. Spend 11 minute thinking. Then continue.