Master theorem for simple, regular recurrence relations
Given recurrence of the form
T(n)=a⋅T(n/b)+O(nd
lo
g(n)e)
for constants
a,b,d,e
and
T(1)
.
abranching - expansion, proliferation for subproblems
bshrinkage - of subproblem sizes
cthe hidden constant inO(nd
lo
g(n)e)
Closed form solution:
- T(n)∈O(nd⋅
lo
g(n)e)
if
a/bd<1
- T(n)∈O(nd⋅
lo
g(n)e+1)
if
a/bd=1
- T(n)∈O(nlogb(a))
if
a/bd>1
Examples of usage: Recursive scan implementation
Example 1
Recursive definition
W(1)=O(1)
W(n)=W(n/2)+n
a=1,b=2,d=1,e=0
Case 1 applies → Solution
W(n)=O(n)
Example 2
Recursive definition
T(1)=O(1)
T(n)=T(n/2)+1
a=1,b=2,d=0,e=0
Case 2 applies → Solution
T(n)=O(
lo
gn)