We can find it using BFS.
when we reach each node we must increment its degree by one..
if we see that there some nodes with degree >=2 then graph is not tree.
1 2011-05-08 13:07:22
Re: Определить или граф есть деревом (3 ответов, оставленных в Algo)
2 2011-05-06 07:36:32
Re: Как найти первые k(k<=9) цифр числа N^N(n<=10^9)? (3 ответов, оставленных в Problems)
it hasn't got so long code:
double len=floor(n*log10(n))+1;
double ost=n*log10(n)+1.0-len;
unsigned long long result=(unsigned long long)(pow(10.0,ost));