int func(int n){ if(n==1) return 0; else return sqrt(n); }
Where sqrt(n) is a C math.h library function.
Let n=2^m Given T(n)=T(sqrt(n))+1 T(2^m)=T(2^m-1)+1 Let T(2^m)=S(m) then, S(m)=2S(m/2)+1 using master theorem- S(m)=theta(m) =theta(log(n)) Hence, time complexity is theta(log(n)).