Академический Документы
Профессиональный Документы
Культура Документы
Seleccin Insercin
2 000
1 000
1 500
800
Tiempo (ms)
1 000 600
400
500
200
0 0
10 20 30 40 10 20 30 40
Mezcla Montculos
10
10
8
Tiempo (ms)
8
6
6
4
4
2
2
10 20 30 40 10 20 30 40
Rpido Mediana
8 0,8
0,6
Tiempo (ms)
6
0,4
4
0,2
2 0
10 15 20 25 30 35 40 10 15 20 25 30 35 40
Tamao del arreglo (miles) Tamao del arreglo (miles)
Figura 1. Tiempos promedio de ejecucin de los algoritmos de ordenamiento por seleccin, insercin, mezcla, montculos, rpido y mediana.
ESTRUCTURAS DE DATOS Y ANLISIS DE ALGORITMOS TAREA I DIEGO CONTRERAS ESTRADA 3
Comparacin
Seleccin
Insercin
103
Mezcla
Montculos
Rpido
Tiempo (ms)
102 Mediana
101
100
10 20 30 40
Tamao del arreglo (miles)
v o i d i n s e r c i o n ( i n t a r r e g l o , i n t tam a o )
{
f o r ( i n t i = 1 ; i < tam a o ; i ++)
{
int copia = arreglo [ i ] ;
int x = i 1;
w h i l e ( x >= 0 && a r r e g l o [ x ] > c o p i a )
{
a r r e g l o [ x +1 ] = a r r e g l o [ x ] ;
x ;
}
a r r e g l o [ x +1 ] = c o p i a ;
}
}
R EFERENCIAS
[1] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction
to Algorithms, 3rd ed. The MIT Press, 2009.