Question on Tree

Revision en3, by back_slash, 2019-03-12 20:19:50

Given an undirected graph which is a tree with N nodes (N >= 3). You have to select an internal node (nodes with degree >= 2) and calculate the sum of the distance of all non-internal nodes (nodes with degree 1) from that node. You have to print the minimum possible value of the sum. And if possible also print the internal node number which gives you the minimum value. If there are multiple internal nodes which give the same minimum sum to all non-internal nodes print any of them. Can we solve this question in less than O(N^2) time complexity??

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English back_slash 2019-03-12 20:19:50 65
en2 English back_slash 2019-03-12 20:18:05 114
en1 English back_slash 2019-03-12 20:14:21 387 Initial revision (published)