Professional Documents
Culture Documents
f( 2k ) = f( 2k - 1 ) + 1, with f( 20 ) = 1.
f( n ) = a.f( n / b ) + c.nd
If ( a < bd ) then f( n ) is O( nd )
If ( a = bd ) then f( n ) is O( ndlogn )
List of size n.
• f( n ) = 2 f( n / 2 ) + cn1.
• a = 2; b = 2; d = 1.
big-O estimate:
Let b = a mod m.
f( n ) = f( n/2 ) + 2
a = 1, b = 2, d = 0.
So, a = bd
If a = bd & n = bk
To show:
f(n) = f(1)nd + cnd logbn is O( nd log n ).
So:
– f(n) growth clearly is dominated by cnd logbn.
– c is a constant.
– logbn differs from log2n by only a constant factor.
( log2b ) . logbn = log2( b logbn ) = log2n.
– cnd logbn therefore is O( nd log n ).
Copyright © Peter Cappello 18
Theorem 1
Let f be an increasing function such that
f(n) = a.f(n/b) + c
whenever b | n, where a ≥ 1, b >1 are integers, & c > 0 is real.
If ( a > 1 ) then f(n) is O( nlogba )
If ( a = 1 ) then f(n) is O( logn ).
When n = bk where k > 0 is integer, and a > 1,
f(n) = C1 nlogba + C2,