views:

35

answers:

1

On my midterm I had the problem:

t(n) = 8T(n/2) +n^3

and I am supposed to find its big theta notation using either the masters or alternative method. So what i did was

a = 8, b = 2 k = 3

log8 (base 2) = 3 = k

therefore, T(n) is big theta n^3. I got 1/3 points so i must be wrong. What did I do wrong?

+2  A: 

T(n) = aT(n/b) + f(n)

You applied the version when f(n) = O(n^(log_b(a) - e)) for some e > 0.

This is important, you need this to be true for some e > 0.

For f(n) = n^3, b = 2 and a = 8,

n^3 = O(n^(3-e)) is not true for any e > 0.

So your picked the wrong version of the Master theorem.

You need to apply a different version of Master theorem:

if f(n) = Theta ((log n)^k * n^log_b(a)) for some k >= 0,

then

T(n) = Theta((log n)^(k+1) * n^log_b(a))

In your problem, you can apply this case, and that gives T(n) = Theta(n^3 log n).


An alternative way to solve your problem would be:

T(n) = 8 T(n/2) + n^3.

Let g(n) = T(n)/n^3.

Then

n^3 *g(n) = 8 * (n/2)^3 * g(n/2)+ n^3

i.e g(n) = g(n/2) + 1.

This implies g(n) = Theta(logn) and so T(n) = Theta(n^3 logn).

Moron
how is f(n) = n^3 = Theta((log n)^k * n ^log_b(a)) ?
Dave
@Roarke: k = 0.
Moron