- Where Developers Learn, Share, & Build Careers


I have been given a question on an assignment that stumped me. I'm thinking very hard about it ... the question is as follows.

Give a linear time algorithm to determine the longest non-detached route in an anaside underride graph (which is a tree).

My first intention is to go with DFS. But it seems DFS tells me the longest route from the node only that I start on the second top; However, the problem asks for the longest path in the tree ... not the longest path from the node, can i set someone directly to me at the beginning?

Thank you.

One such method is the distance for all nodes, A, and all other nodes in linear time. Counting of. Suppose is far from the BA. In step 2, find the node far away from B.

Let the command (p, q) denote the distance from the p to the queue. Note that if E is the lowest common ancestor A, B, C, then D (A, B) = D (A, E) + D (E, B) and also note that D (E, B) A ?? ¥ D (E, C).

Edit 1: algorithm or method ??? Find the most distant B from any A; Find the distance from B to B; The claim is that D (B, C) seems to have more than all the top pairs in the graph, but the above does not prove it.

On the one hand, it should not be that D (E, B) a ?? ¥ D (E, C), and on the other, that alone will not be enough to establish D (B, C) - ¥ D (F, G), where there are no nodes in the F.G tree ...

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -