performance - What is Time Complexity of the following function? -
int dosomething(int n) { if(n < 2) return 1; else return dosomething(floor(sqrt(n))) + n; }
according me corresponding recurrence :
solving recurence...
putting
the function becomes
can please verify & rectify solution?
you correct upto :-
s(m) = o(log(m))
then
t(2^m) = o(log(m)) n = 2^m t(n) = o(log(m)) m = log(n) hence t(n) = log(log(n))
Comments
Post a Comment