GATE CSE
First time here? Checkout the FAQ!
x
0 votes
172 views
1) T(n)=T(n-1)+1/n.
2) T(n)=T(n-1) +1/log(n)

3)T(n)=3T((n/3) - 2)+n/2.
4)T(n)=T(n/2)+T(n/4)+T(n/8)+n.
Use Masters theorem
asked in Algorithms by Active (1.3k points)  
edited by | 172 views
I dont think master theorem can be applied for this..for the first one it just a harmonic series it will be O(logn).Try subsitution method.

2 Answers

0 votes
t(n)=t(n/2)+t(n/4)+t(n/8) +n;

the above equation can be reduced to

T(n)<3T(n/2)+n

here a=3;b=2

so

a>b

hence by masters theorem T(n)=θ(n^log3 to base 2)
answered by Junior (507 points)  
0 votes

Question 1: Master Theorem not possible since b=1, which is not greater than 1.
Question 2: Master Theorem not possible since b=1, which is not greater than 1.
Question 3:
T(n)=3T( (n/3) - 2 ) +n/2 = 3T((3n-6)/3)+n/2 = 3T(3(n-2)/3)+n/2 = 3T((n-2))+n/2
Now, Master Theorem not possible since b=1, which is not greater than 1.

Question 4: T(n)=T(n/2)+T(n/4)+T(n/8)+n

Roughly, T(n) can be written as T(n)<T(n/2)+T(n/2)+T(n/2)+n, which can be further reduced to
T(n)<3T(n/2) + n
Now, a = 3, b=2, k=1, p=0
Clearly, a > bk i.e. 3>21.

So, Case 1 satisfies. Therefore, T(n)=Theta(nlg3) = Theta(n1.584962...) = Theta(n)

I hope it helps. :)

answered by (11 points)  


Top Users May 2017
  1. akash.dinkar12

    3598 Points

  2. pawan kumarln

    2314 Points

  3. Bikram

    1958 Points

  4. Arjun

    1942 Points

  5. sh!va

    1682 Points

  6. Debashish Deka

    1296 Points

  7. Devshree Dubey

    1282 Points

  8. Arunav Khare

    1122 Points

  9. Angkit

    1072 Points

  10. LeenSharma

    1028 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 29 - Jun 04
  1. Arjun

    292 Points

  2. Arunav Khare

    246 Points

  3. Rupendra Choudhary

    116 Points

  4. Arnab Bhadra

    116 Points

  5. pC

    110 Points


22,912 questions
29,253 answers
65,411 comments
27,750 users