views:

73

answers:

1

hi all,
we know how to computer diameter but i came across a question where they asked you to print this longest path .. how can it be done?

A: 

longest path? can you be more clear in question? I mean longest path can be the circumference in case u travel alon the circle boundary.. your question is no in sync with title..

He's talking about "the diameter of a graph" (note that a tree is a subset of a graph) not that of a circle. The question could use a little clarification, however.
dmckee
I think then that boils down to finding the inverse of shortest path problem for every node and then print the node which has the longest path?