Professional Documents
Culture Documents
UNIVERSIDAD DE CARABOBO
FACULTAD EXPERIMENTAL DE CIENCIAS Y TECNOLOGA
DEPARTAMENTO DE COMPUTACIN
GRUPO DE DESARROLLO DE SOFTWARE Y SISTEMAS
CS218 ALGORITMOS Y PROGRAMACIN II
PRCTICA 4
(FUNDAMENTOS DE ANLISIS ASINTTICO DE ALGORITMOS)
1. Suponga que para resolver un problema especfico existen dos algoritmos Pa y Pb. El algoritmo Pa tiene
un tiempo de ejecucin Ta(n) = n2 + 10 y el algoritmo Pb tiene un tiempo de ejecucin Tb(n) = 200n + 4.
Cul de los dos algoritmos es ms eficiente y por qu?
2. Calcular la complejidad en tiempo del peor caso de cada uno de los siguientes algoritmos. Exprese los
resultados utilizando la notacin O-grande.
a.
c.
e.
b.
d.
f.
end_for;
end_for;
end_for;
end;
h.
i.
j
.
k.
l
.
fib_rec(n
1)
fib_rec(n - 2)
end_if;
end;
j.
2)
3. Calcular la complejidad en espacio asociada a cada una de las siguientes estructuras de datos.
c.
type
tip_r1 = (a1, a2, a3, a4, a5, a6);
tip_r2 = (b1, b2, b3, b4 , b5, b6, b7, b8);
tip_r3 = (c1, c2, c3, c4);
Fecha = register
dia : [ 1 .. 31 ];
mes : [ 1 .. 12 ];
ao : [ 1950 .. 2100 ]
fregister;
info_r1 = register
categora : (ca1, ca2, ca3);
cantidad : Integer;
lote : Integer;
costo : Real
fregister;
info_r2 = register
categora : (cb1, cb2, cb3, cb4);
cantidad : Integer;
fecha_vencimiento : Fecha;
costo : Real
fregister;
info_r3 = register
categora : (cc1, cc2, cc3);
peso : Real;
lote : Integer;
costo : Real
fregister;
R = register
r1 : array [ tip_r1 ] of info_r1;
r2 : array [ tip_r2 ] of info_r2;
r3 : array [ tip_r3 ] of info_r3
fregister;
var
femenino :
fcase;
fregister;
emps = array [ 1 .. 5000 ] of datos;
empresa = register
nombre : cadena[ 30 ];
empleados : emps
fregister;
var
REY_Computers : empresa;
(num_hijos : Integer;
edad : [ 1 .. 70 ];
case estado_civil : (soltera, casada, divorciada) of
soltera : (estatura, peso : Real);
casada : (nombre_esposo : cadena[ 20 ]);
divorciada : (fecha_divorcio : Fecha)
fcase;