Let T(n) = T(n/2) + log(n). Give matching upper and lower bounds for T(n):
Using a recursion tree
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
The tree can be shown as
T(n)------log(n)
|
|
T(n/2)----log(n/2)
|
|
T(n/4)----log(n/4)
|
|
..
..
..
|
T(1)---log(1)
The depth of the tree is log2(n)
So,
Total operations added are
T(n)=log2(n)+log2(n/2)+log2(n/4)+......log2(n/2^d) where d is depth
So,
T(n)<=log2(n)+log2(n)+.....log2(n) (d times)
So,
T(n)<=d*log2(n)
So,
T(n)<=(log2(n))^2
Also,
T(n)>=log2(n/2)+log2(n/2)+log2(n/2)........d times
So,
T(n)>=d*log2(n/2)
So,
T(n)>=(log2(n))^2-log2(n)
So,
T(n)=Theta((log2(n))^2)
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.