PRÁCTICA 1
IVÁN GARZÓN SEGURA
ÁNGEL RODRÍGUEZ HÓDAR
ANTONIO MOLNER DOMENECH
RAÚL SÁNCHEZ FERNÁNDEZ
VÍCTOR ALEJANDRO VARGAS PÉREZ
Especificaciones
CPU: Intel® Core™ i5-6300HQ
- Número de núcleos: 4
- Frecuencia de reloj: 2,3 Ghz
- SO: Ubuntu 14.04 LTS
- Carga del sistema: mínima
Cálculo del tiempo
clock_t antes;
clock_t despues;
double media = 0;
for (size_t i = 0; i < 3; i++) {
for (int i = 0; i < n; i++) {
T[i] = random();
};
antes = clock();
heapsort(T, n);
despues = clock();
media = media + (despues - antes) / 3;
}
cout << n << '\t' << media / CLOCKS_PER_SEC << endl;
Ejecución
#!/bin/bash
#FORMATO: ./script.sh <PROGRAMA> <INCREMENTO> <ITERACIONES>
#SALIDA: fichero de texto de nombre <PROGRAMADATA.TXT>
inc=$2
arg=$inc
iter=$3
rm data$1.txt
for (( i = 0; i < $iter; i++)); do
echo $arg
./$1 $arg >> ./data$1.txt
arg=$[ $inc + $arg ]
done
Algoritmos de orden O(n²)
Burbuja
Selección
Inserción
Comparativa
Algoritmos de orden O(nlog(n))
Heapsort
Mergesort
Quicksort
Comparativa
O(n²) vs O(nlog(n))
Otros órdenes
Hanoi
O(2^n)
O(2n)
Floyd
O(n^3)
O(n3)
Eficiencia Híbrida
Burbuja
function used for fitting: g(x)
g(x) = a*x*x
After 3 iterations the fit converged.
final sum of squares of residuals : 0.0338721
rel. change during last iteration : -6.971e-08
Final set of parameters
=======================
a = 2.95178e-09
Asymptotic Standard Error
==========================
+/- 9.402e-12 (0.3185%)
Insercion
function used for fitting: g(x)
g(x) = a*x*x
After 3 iterations the fit converged.
final sum of squares of residuals : 0.0369889
rel. change during last iteration : -2.25015e-09
Final set of parameters
=======================
a = 1.12738e-09
Asymptotic Standard Error
==========================
+/- 9.825e-12 (0.8715%)
Selección
function used for fitting: g(x)
g(x) = a*x*x
After 4 iterations the fit converged.
final sum of squares of residuals : 0.0218379
rel. change during last iteration : -6.35491e-16
Final set of parameters
=======================
a = 1.4699e-09
Asymptotic Standard Error
==========================
+/- 7.55e-12 (0.5136%)
Heapsort
function used for fitting: f(x)
f(x) = a*x * log(x)
After 5 iterations the fit converged.
final sum of squares of residuals : 0.0196566
rel. change during last iteration : -1.76503e-16
Final set of parameters
=======================
a = 2.37907e-08
Asymptotic Standard Error
==========================
+/- 1.335e-10 (0.561%)
Mergesort
function used for fitting: f(x)
f(x) = a*x * log(x)
After 3 iterations the fit converged.
final sum of squares of residuals : 0.0269555
rel. change during last iteration : -1.72414e-08
Final set of parameters
=======================
a = 1.8035e-08
Asymptotic Standard Error
==========================
+/- 1.563e-10 (0.8667%)
Quicksort
function used for fitting: f(x)
f(x) = a*x * log(x)
After 3 iterations the fit converged.
final sum of squares of residuals : 0.00209986
rel. change during last iteration : -3.55973e-08
Final set of parameters
=======================
a = 1.19859e-08
Asymptotic Standard Error
==========================
+/- 4.363e-11 (0.364%)
Hanoi
function used for fitting: f(x)
f(x) = a*2**x
After 5 iterations the fit converged.
final sum of squares of residuals : 2.19399
rel. change during last iteration : -2.42894e-15
Final set of parameters
=======================
a = 6.04719e-09
Asymptotic Standard Error
==========================
+/- 7.322e-12 (0.1211%)
Floyd
function used for fitting: f(x)
f(x) = a*x*x*x
After 4 iterations the fit converged.
final sum of squares of residuals : 0.000387746
rel. change during last iteration : -2.44664e-14
Final set of parameters
=======================
a = 5.27167e-09
Asymptotic Standard Error
==========================
+/- 2.147e-12 (0.04072%)
Floyd mal ajustado
function used for fitting: f(x)
f(x) = a*x
After 4 iterations the fit converged.
final sum of squares of residuals : 10.8864
rel. change during last iteration : -3.26345e-16
Final set of parameters
=======================
a = 0.00249242
Asymptotic Standard Error
==========================
+/- 0.0001854 (7.437%)
COMPARATIVAS
Inserción y Floyd
-O2 VS -O3
Inserción
Core2Duo vs Intel i5
MACBOOK PRO 2012
i5-3210M CPU @ 2.50GHz
2 cores físicos y 4 lógicos
OS X vs Ubuntu
ASUS GL552VW
i5-6300HQ CPU @ 2.3GHz
4 cores físicos y 4 lógicos
OS X vs Ubuntu
Hanoi y Floyd
FIN
Practica 1 Algorítmica
By Antonio Molner
Practica 1 Algorítmica
- 248