I\'ve been presented the following problem in University:
Let G = (V, E) be an (undirected) graph with costs ce >= 0 on the edges e<
I think a BFS would suffice. And it's complexity is O(|V| + |E|) but in a tree |E| is less than |V| so it's O(2|V|) that is O(|V|)