0% found this document useful (0 votes)
25 views7 pages

Unit I Introduction To Algoritm Design Session - 8

The document discusses the Master's theorem method for solving recurrence relations of the form T(n) = aT(n/b) + f(n). There are three cases: 1) if f(n) is smaller than nlogba, then T(n) is Θ(nlogba); 2) if f(n) is equal to nlogba up to logarithmic factors, then T(n) is Θ(nlogbalogn); 3) if f(n) is larger than nlogba and satisfies regularity conditions, then T(n) is Θ(f(n)). Several examples are provided and solved using this method.

Uploaded by

Cooldude 69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

Unit I Introduction To Algoritm Design Session - 8

The document discusses the Master's theorem method for solving recurrence relations of the form T(n) = aT(n/b) + f(n). There are three cases: 1) if f(n) is smaller than nlogba, then T(n) is Θ(nlogba); 2) if f(n) is equal to nlogba up to logarithmic factors, then T(n) is Θ(nlogbalogn); 3) if f(n) is larger than nlogba and satisfies regularity conditions, then T(n) is Θ(f(n)). Several examples are provided and solved using this method.

Uploaded by

Cooldude 69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIT I

INTRODUCTION TO ALGORITM
DESIGN

Session – 8
Master’s theorem method
 Master Method is a direct way to get the solution. The master method
works only for following type of recurrences or for recurrences that can
be transformed to following type.

T(n) = aT(n/b) + f(n) where a >= 1 and b > 1 and f(n) is an asymptotically
positive function.
 There are following three cases:

1. If f(n) < O(nlogba), then T (n) = ϴ (nlogba).

2. If f(n) = ϴ (nlogba) , then T (n) = ϴ (nlogbalogn).

3. If f(n) > Ω (nlogba), and f(n) satisfies the regularity condition, then T
(n) = ϴ (f(n)).
Solve the problems
T(n) = 3T(n/2) + n2
T(n) = 7T(n/2) + n2
T(n) = 4T(n/2) + n2
T(n) = 3T(n/4) + n lg n
T(n) = 3T(n/2) + n2
T(n) = aT(n/b) + f(n) where a >= 1 and b > 1
a=3 b = 2 f(n) = n2

1. If f(n) < O(nlogba), then T (n) = ϴ (nlogba).

2. If f(n) = ϴ (nlogba) , then T (n) = ϴ (nlogbalogn).

3. If f(n) > Ω (nlogba), and f(n) satisfies the regularity condition, then T (n) =
ϴ (f(n)).
Step 1: Calculate nlogba = nlog23 = n1.58
Step 2: Compare with f(n)
Since f(n) > nlogba
i.e. n2 > n1.58
Step 3: Case 3 is satisfied hence complexity is given as
T(n) = Θ(f(n)) = Θ (n2)
T(n) = 7T(n/2) + n2
T(n) = aT(n/b) + f(n) where a >= 1 and b > 1
a=7 b=2 f(n) = n2
1. If f(n) < O(nlogba), then T (n) = ϴ (nlogba).

2. If f(n) = ϴ (nlogba) , then T (n) = ϴ (nlogbalogn).


3. If f(n) > Ω (nlogba), and f(n) satisfies the regularity
condition, then T (n) = ϴ (f(n)).
Step 1: Calculate nlogba = nlog27= n2.80
Step 2: Compare with f(n)
since f(n) < nlogba
Step 3: Case 1 is satisfied hence complexity is given as
T(n) = Θ (nlogba) = Θ (n2.8)
T(n) = 4T(n/2) + n2
T(n) = aT(n/b) + f(n) where a >= 1 and b > 1
a=4 b=2 f(n) = n2

1. If f(n) < O(nlogba), then T (n) = ϴ (nlogba).

2. If f(n) = ϴ (nlogba) , then T (n) = ϴ (nlogbalogn).

3. If f(n) > Ω (nlogba), and f(n) satisfies the regularity condition, then T (n)

= ϴ (f(n)).

Step 1: Calculate nlogba = nlog24= n2

Step 2: Compare with f(n) // Since f(n) = nlogba * log0n

Step 3: Case 2 is satisfied hence complexity is given as

T(n) = Θ (f(n)logn) = Θ (n2logn)


Worksheet No. 8

You might also like