Distance Between Nodes in A General Tree

Правка en1, от issahaddar5, 2015-09-06 13:18:09

I am trying to solve this. The graph is a tree, so I represented it as disjoint sets. To find the distance between two nodes I am finding the first common ancestor and adding the distances to reach this ancestor form the starting node and the target node. this is my code and unfortunately its giving wrong answer upon submission.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский issahaddar5 2015-09-06 13:18:09 436 Initial revision (published)