Maximum matching in a tree

743 Views Asked by At

We were asked to suggest a dynamic program algorithm to Find maximum matching in a tree in linear time, $O(|V|+|E|)$.

I have no clue how to start. any Ideas?

1

There are 1 best solutions below

1
On BEST ANSWER

Hint:

Denote by $A(v,\text{True})$ the maximal matching in the sub-tree where $v$ is its root, where edges with one endpoint equal to $v$ are allowed.

Denote by $A(v,\text{False})$ the maximal matching in the sub-tree where $v$ is its root, where edges with one endpoint equal to $v$ are not allowed.

Feel free to ask for some clarifications if this does not help you :)