Awesome q2a theme
0 votes
31 views
what is the time complexity

in f( int n) {

if(n <=2)

return 1

else

return f(floor(sqrt(n))) + n;

}
closed with the note: Duplicate: https://gateoverflow.in/226144/time-complexity
in Algorithms by (9 points) 1 flag
closed by | 31 views
0

Duplicate: https://gateoverflow.in/226144/time-complexity

Check for duplicates before asking a question.

Read rules: https://csedoubts.gateoverflow.in/blog/1/guidelines-to-users

1 Answer

0 votes
Recursive relation for f() is.

T(n)= T($\sqrt{n}$)+ C1   if n>2

i ignored the floor() part as it doesn’t matter here.

Let n= $2^{m}$ , T(n) = T($2^{m}$)

Let  T($2^{m}$) = S(m)

S(m) = S(m/2) + C1

S(m) = O(logm)

         = O(loglogn)      because n=$2^{m}$

 

Now our original recursive function T(n)

     T(n) = S(m)

             =O(loglogn)
by (5 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
9,270 questions
3,204 answers
14,751 comments
96,304 users