In: Computer Science
Derive a Θ-bound on the solution to the following recurrence. using iterative recursion and check your answer with master theorem result
T(n) = T (1/3 n) + log n
Hi,
------------------------------------------------------------------
T(n) = T (1/3 n) + log n
T(n) = T (n/31) + log n
=T(n/32) + log(n/31)+log(n/30)
=T(n/33) + log(n/32) + log(n/31)+log(n/30)
=T(n/34) + log(n/32) + log(n/31)+log(n/30)
+................+
if n= 3k then n/3k =1 and k= log3n and T(1)=1
=T(n/3k) +log(n/3k-1) + log(n/3k-2) + ..............+ log(n/32) + log(n/31)+log(n/30)
=T(1) + log(n/3k-1) + log(n/3k-2) + ..............+ log(n/32) + log(n/31)+log(n/30)
=1+ log(n/3k-1) + log(n/3k-2) + ..............+ log(n/32) + log(n/31)+log(n/30)
=1+ log(3k/3k-1) + log(3k/3k-2) + ..............+ log(3k/32) + log(3k/31)+log(3k/30) ∵ n= 3k
=1+ log3 + log32 + .....+ log3k-2 + log3k-1 + log3k
=1+ log33 + 2log33 + .....+ (k-2)log33 + (k-1)log33 + (k)log33
=1+1+2+....+(k-2)+(k-1)+k
=1+ k(k+1)/2
=1+ k2/2 + k/2
=1+( log2n)/2 +( logn)/2
now we ignore the constant terms and smaller terms.
T(n) = Θ(log2n) <---Answer
----------------------------------------------------------------------------------------------
Using Master Theorem
if T(n) =aT(n/b)+f(n) then T(n) = Θ(nlogba)
-----------------------------------------------------------
given T(n) = T (n/3) + log n
so a = 1 and b = 3 and f(n) =Θ log(n) where k =1
---------------------------------------------------
then T(n) = Θ(nlogba) = Θ(nlog31) = Θ(1)
here T(n) is logarithm time smaller than f(n)
----------------------------------------------------------
using master theorem special case :
if nlogba is logarithm time smaller than f(n) then T(n) = Θ(nlogba(log)k+1)
------------------------------------------------------------------------
so T(n) = Θ(nlog31(log)1+1) ∵ log31 = 0
T(n) = Θ(n0(log)1+1) ∵ n0 = 1
T(n) = Θ(log2n) <---Answer
Conclusion: Iterative and master theorem both produce same result.
----------------------------------------------------------------------------------
Still if you have any doubt or need any kind of improvement, please let me know in comment section and if you like, Please upvote.
Thank You !