Give an algorithm with linear time to check if the tree has a perfect match, i.e. a set of edges that touches each vertex of the tree exactly once.
This is from the algorithms of S. Dasgupt, and I just can not cover up this problem. I know that I need to use the greedy approach somehow, but I just can't figure it out. Help?
Pseudo code is fine; as soon as I have an idea, I can implement it in any language trivially.
The algorithm should be linear in everything. O (V + E) is excellent.
source
share