Question 21
The solution of the recurrence relation
T(m) = T( 3m/4) + 1 is :
Answer : (1) θ (lg m) T(m) = T( 3m/4) + 1 is :
Previous | Next |
UGC NET CS 2018 July - II Question 20 | UGC NET CS 2018 July - II Question 22 |
In this problem we use Master’s Theorem:
T(m)
= T(3m/4) + 1
= T(m/(4/3)) + 1
Now, compare above equation with below equation,
T(m) = aT(m/b) + nklogpn
then, we can get a = 1, b = 4/3, k = 0 and p = 0
Here, From above values we can conclude that we have to apply case 2 of Master's Theorem
a = 1 = b0 = bk
∴ a=bk
So, Apply case 2 of Master's Theorem
Here, p>-1,
∴ case 2 - (a) will be applicable from below master theorem.
∴ T(m) = θ( m(logba)log(p+1)m)
So, now after substituting values a=1, b=4/3, k=0 and p=0 in above equation.
∴ T(m) = θ( m(log4/31)log(0+1)m)
Now applying, log4/31 = 0
∴ T(m) = θ( m0log1m)
∴ T(m) = θ(log m)
So, Option (1) is correct answer.
Algorithms: Masters theorem
T(n) = a T(n/b) + Θ(nk logp n) where a > = 1, b > 1, k > = 0 , and p is real number
Case 1: if a > bk, Then T(n) =Θ(n^(logba))
Case 2: a = bk
a)if p > -1, Then T(n) = Θ( n(logba)log(p+1)n)
b)if p = -1, Then T(n) = Θ( n(logba)loglogn)
c) if p < -1, Then T(n) = Θ( n(logba))
Case 3: a < bk, a)if p > =0, then T(n) = Θ(nk logp n))
b) if p<0 then T(n) = Θ(nk)