Pregunta

Given the equation T(n)=sqrt(2)T(n/2)+log(n).

The solution points to case 1 of the M.T. with a complexity class of O(sqrt(n)). However after my understanding log(n) is polynomial greater then sqrt(n). Am I missing something?

I used the definition as following: n^e = log_b(a) where a = sqrt(2) and b = 2. This would give me e = 1/2 < 1. log n is obviously polynomial greater then n^e.

¿Fue útil?

Solución

No. logx n is not greater than √n.

Consider n=256,

√n = 16,

and

log2 256 = 8 (let us assume base x=2, as with many of the computational problems).

In your recurrence,

T(n)= √2 T(n/2) + log(n)
a = √2, b = 2 and f(n) = log(n)

logb a = log2 √2 = 1/2.

Since log n < na, for a > 0, We have Case 1 of Master Theorem.

There for T(n) = Θ(√n).

Otros consejos

Using the masters theorem you get: a=sqrt(2), b = 2 and therefore c = logb(a) = 1/2. Your f(n) = log(n) and therefore you fall into the first case.

So your complexity is O(sqrt(n))

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top