Graph Theory37 sections · 1633 units
Open in Course

Think First

(Pause before reading)

Before you continue, pause and think:

1.1. Is this a one-root problem or all-roots problem? (Hint: Read 'for each employee')

2.2. Do you need states or collect counts? (Hint: Are you choosing between options?)

3.3. what is the simplest approach that works? (Hint: Can you solve it with one DFS?) Try to write pseudocode for the DFS. What does dfs(u, parent) return? What do you store? How do you combine child results? Think for at least 3030 seconds. Then move to the next unit.