문제

I was thinking on a homework question given to me, it is as follows: If you are given with a BFS and DFS traversal of a directed( or un-directed graph), how would you find the original graph ? Is it possible in either case?

thankyou

도움이 되었습니까?

해결책

If I understand it correctly, it is not possible, since BFS and DFS produce a tree, and tree has |V|-1 edges. So, in these two trees you have at most 2|V|-2 different edges, and original graph can have up to |V|(|V|-1) edges for directed, and |V|(|V|-1)/2 for undirected graph.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top