Cómo resolver esta recurrencia T (n) = T (sqrt (n)) + log_2 n

¡Puedes resolver este problema con una simple sustitución!

[matemáticas] T (n) = T (\ sqrt {n}) + \ log {n} [/ matemáticas]

Sustituyendo [matemáticas] n = 2 ^ {m} [/ matemáticas], obtenemos:

[matemáticas] T (n) = T (2 ^ {m}) = T (\ sqrt {2 ^ {m}}) + \ log {2 ^ {m}} = T (2 ^ {m / 2}) + m [/ matemáticas]

Deje que [matemática] S (m) [/ matemática] se defina como [matemática] S (m) = T (2 ^ m) = T (2 ^ {m / 2}) + m [/ matemática]. (*)

Tenga en cuenta que [matemáticas] S (m / 2) = T (2 ^ {m / 2}) [/ matemáticas], entonces por (*):

[matemáticas] S (m) = S (m / 2) + m [/ matemáticas].

Ahora puede usar el Teorema maestro para resolver esta recursión en términos de [matemáticas] S (m) [/ matemáticas], para obtener:

[matemáticas] S (m) = \ Theta (m) [/ matemáticas]

También podría haber deducido este resultado al observar que en su recursión, combinar los subproblemas lleva tiempo [matemático] \ Theta (m) [/ matemático], que domina el tiempo que tarda la recursión en ejecutarse (tiempo logarítmico).

Para finalizar, sustituimos [math] m = \ log {n} [/ math] para obtener:

[matemáticas] S (m) = T (2 ^ m) = T (2 ^ {\ log {n}}) = T (n) = \ Theta (m) = \ Theta (\ log {n}). [ /mates]

Despejando el desorden, [matemáticas] T [/ matemáticas] [matemáticas] (n) = \ Theta (\ log {n}) [/ matemáticas]

[matemáticas] T (n) [/ matemáticas]

[matemáticas] = T (\ sqrt {n}) + log_2 n [/ matemáticas]

[matemáticas] = T (\ sqrt {\ sqrt {n}}) + (1 + \ frac {1} {2}) log_2 n [/ matemáticas]

[matemáticas] = T (\ sqrt {\ sqrt {\ sqrt {n}}}) + (1 + \ frac {1} {2} + \ frac {1} {4}) log_2 n [/ matemáticas]

[matemáticas] =… [/ matemáticas]

[matemáticas] = (1 + \ frac {1} {2} + \ frac {1} {4} + \ frac {1} {8} +…) log_2 n [/ matemáticas]

[matemáticas] = O (log_2 n) [/ matemáticas]