0

What is the time complexity of the following recursive function

int DoSomething(int n){ if(n<=2) return 1; else return (DoSomething(floor(sqrt( n) )) + n); } 

Options are:-

  1. O(n^2)
  2. O(n log n) //all logs are with base 2
  3. O(log n )
  4. O(log log n )
2
  • as it is, this is a bad question. this is clearly a homework problem and you have not demonstrated any effort to solve it on your own. not that you likely care, but here's how to ask a question Commented Jun 29, 2017 at 6:36
  • Well, this is not a homework problem, this was on GATE 2007 paper. Commented Jun 30, 2017 at 6:28

1 Answer 1

3

The time complexity function is (ignoring floor as it is asymptotically irrelevant):

enter image description here

We need to find m when the algorithm terminates, i.e. when:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.