Question

Given a tree, find a path on which every vertex has at most 4 leaves (can have 0 as well) and is the "biggest" (has the maximum amount of vertices possible - including the leaves). Time complexity: $O(n)$.

I'm getting nowhere with this problem. I have tried BFS/DFS (seemed like such an obvious method), but even if I could modify them correctly, their time complexity is $O(|V|+|E|)$.

Any hint, thought is appreciated.

edit: so now I get that BFS/DFS is valid for this problem, but I'm still having difficulties with figuring out the algorithm itself. Help please.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top