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?
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?
Copyright © 2021 JogjaFile Inc.
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 :)