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 :

recurence relatio

solving recurence...

putting substitute 1

the function becomes

rest of image

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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -