树的最长路径指的是树上两个节点的最大距离。
Algorithm:
- Run BFS or DFS from any node to find the farthest leaf node. Label that node T.
- Run another BFS or DFS to find the farthest node from T.
- The path you found in step 2 is the longest path in the tree.
转载http://www.quora.com/How-does-following-algorithm-for-finding-longest-path-in-tree-work