CapÃtulo 3 Complejidad de algoritmos recursivos ⩠⨠⧠= > â = 0 1 0 ...
CapÃtulo 3 Complejidad de algoritmos recursivos ⩠⨠⧠= > â = 0 1 0 ...
CapÃtulo 3 Complejidad de algoritmos recursivos ⩠⨠⧠= > â = 0 1 0 ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Instituto Tecnológico <strong>de</strong> Ciudad Ma<strong>de</strong>ro<br />
Dra. Laura Cruz Reyes<br />
Unidad I COMPLEJIDAD DE ALGORITMOS<br />
Capítulo 3 <strong>Complejidad</strong> <strong>de</strong> <strong>algoritmos</strong> <strong>recursivos</strong><br />
En cada nivel el número <strong>de</strong> subproblemas aumenta en potencias <strong>de</strong> dos.<br />
( 2 0 ) →( 2 1 ) →( 2 2<br />
) →... → ( 2 m<br />
)<br />
En cada nivel el tamaño más gran<strong>de</strong> <strong>de</strong> problema disminuye por un factor <strong>de</strong> (2/3) i .<br />
0 1 2 m−1<br />
⎛2⎞ ⎛2⎞ ⎛2⎞ ⎛2⎞ ⎛2⎞<br />
⎜ ⎟ n→⎜ ⎟ n→⎜ ⎟ n→...<br />
→⎜ ⎟ n→⎜ ⎟ n<br />
⎝3⎠ ⎝3⎠ ⎝3⎠ ⎝3⎠ ⎝3⎠<br />
En cada nivel la complejidad algorítmica permanece constante.<br />
m<br />
⎛⎛2<br />
⎞ ⎞<br />
n → n → n → → T n<br />
⎜⎜<br />
⎟<br />
⎝3<br />
⎠ ⎟<br />
⎝ ⎠<br />
m<br />
( ) ( ) ( ) ... ( 2 )<br />
Usando el patrón <strong>de</strong> complejidad y las condiciones <strong>de</strong> terminación, la recurrencia se expresa<br />
como una sumatoria. Dado que esta sumatoria correspon<strong>de</strong> a la trayectoria más larga<br />
(subproblemas mayores), se obtiene una cota superior <strong>de</strong> las trayectorias restantes.<br />
m<br />
⎛<br />
m ⎛2<br />
⎞ ⎞<br />
Tn ( ) ≤ n+ n+ n+ ... + n+ ( 2 ) T n<br />
⎜⎜<br />
⎟<br />
⎝3<br />
⎠ ⎟<br />
⎝ ⎠<br />
m−1<br />
∑<br />
Tn ( ) ≤ ( n) + 0<br />
i=<br />
0<br />
El valor <strong>de</strong> m se <strong>de</strong>termina igualando las dos expresiones que representan la condición <strong>de</strong><br />
paro.<br />
m<br />
⎛2<br />
⎞<br />
T⎜<br />
⎟ n=<br />
T(1)<br />
⎝3<br />
⎠<br />
⎛2<br />
⎞<br />
⎜ ⎟<br />
⎝3<br />
⎠<br />
⎛3<br />
⎞<br />
⎜ ⎟<br />
⎝2<br />
⎠<br />
m<br />
m<br />
m<br />
n = 1<br />
= n<br />
⎛3<br />
⎞<br />
log ⎜ ⎟ = log<br />
⎝2<br />
⎠<br />
m=<br />
log n<br />
3/2 3/2<br />
3/2<br />
m<br />
n<br />
Para la solución <strong>de</strong> T(n) se usa una diferencia <strong>de</strong> límites.