SyntaxFix
Write A Post
Hire A Developer
Questions
T(n)=T(n/2)+1
T(n/2)= T(n/4)+1+1
Put the value of The(n/2) in above so T(n)=T(n/4)+1+1 . . . . T(n/2^k)+1+1+1.....+1
=T(2^k/2^k)+1+1....+1 up to k
=T(1)+k
As we taken 2^k=n
K = log n
So Time complexity is O(log n)