The Master Theorem
The Master Theorem
The Master Theorem
Let a>= 1 and b>1 be constants, let f(n) be a function, and let
T(n) be defined on the non negative integers by the
recurrence
T(n) = 2T(n/2) + n
a = 2, b = 2, log22 = 1
T(n) = (nlgn)
5
Examples
T(n) = 2T(n/2) + n2
a = 2, b = 2, log22 = 1
T(n) = 2T(n/2) + n
a = 2, b = 2, log22 = 1
T(n) = (n)
7
Not solvable using Master Theorem
Examples
T(n) = 3T(n/4) + nlgn
a = 3, b = 4, log43 = 0.793
T(n) = (nlgn) 9
Examples
T(n) = 2T(n/2) + nlgn
a = 2, b = 2, log22 = 1
10
n
logb a
f (n) O n logb a
0
T (n) n logb a
log n
f ( n) n
logb a
c 1
f (n)
f (n) n logb a AND
af (n / b) cf (n) for large n