Awesome q2a theme
0 votes
what is the time complexity

in f( int n) {

if(n <=2)

return 1


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

closed with the note: Duplicate:
in Algorithms by (9 points) 1 flag
closed by | 31 views


Check for duplicates before asking a question.

Read rules:

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)

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
96,304 users