I don't understand what you mean when you say minimum among all the
nodes in the graph.
In any case, your definition of centre of tree looks similar to the
closeness centrality measure -
http://www.faculty.ucr.edu/~hanneman/nettext/C10_Centrality.html#Closeness
I doubt you can do it in O(N)...
Wonder if this works:
x = A / 10^(a-1) // take it as a decimal value itself
y = B / 10^(b-1) // take it as a decimal value itself
if x * y = 10.0
return (a+b)
else
return (a+b-1)
One advantage of the above method is that it can be done mentally.
On Sep 20, 10:47 am, Dave