567 views

1 Answer

0 votes
0 votes

The question contains anchor condition IF(N>=2)  RETURN 1;  

Thus if the function DOSOMETHING() is called with any n>=2 it will take constant time and return 1 without involving any recursion.and if is is called with n<2 ... lets say 1. it will return sqrt(1) + 1 = 2... that to without involving any recursion and will  again take constant time O(1).

However if the question would have been  with anchor condition IF(N<=2) RETURN 1 and recursion statement

return DOSOMETHING(FLOOR(SQRT(N))) +N  Then it could be solved using master`s theorem or recursion tree method with Time Complexity being log2log2n .

edited by

Related questions

0 votes
0 votes
0 answers
2
0 votes
0 votes
1 answer
3
NeelParekh asked Jul 27, 2023
279 views
If an array is split in the form of increasing and decreasing order then what is TC to find minimum element in the array?
2 votes
2 votes
1 answer
4
h4kr asked Dec 30, 2022
473 views
What is the correct time complexity in $\theta()$ ?