24.10.2014 Views

Divide y Vencerás - UPV

Divide y Vencerás - UPV

Divide y Vencerás - UPV

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EDA<br />

2004/2005<br />

<strong>Divide</strong> y Vencerás: MergeSort<br />

Coste MergeSort<br />

• si se descompone el problema original en dos subproblemas balanceados:<br />

t merSort (n) ˛ Q(n*log 2 n)<br />

Coste Merge: t merge (n) ∈ Θ(n)<br />

Caso 4 Teorema (con a==c==2):<br />

f(n) = a*f(n/c) + b*n + d a < c ⇒ Θ(n)<br />

a = c ⇒ Θ(n log c n)<br />

a > c ⇒ Θ(n log c a )<br />

• sino, si por ejemplo se descompone el problema original en dos<br />

subproblemas de talla n-1 y 1 (problema de balanceo): t merSort (n) ∈ Θ(n 2 )<br />

Paolo Rosso Grupos: 2B+ENG - ETSIA

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!