You are on page 1of 2

Taller 1

contenido
sumatorias

Text
Realizar 5 ejercicios de sumatorias, 1 de selección, 1 de burbuja y 1 de inserción
Nombre: Brayan Alexis Cuellar Anturi

ejercicio 1
PROCEDURE Algoritmo1 (VAR a:vector);
VAR i,j: CARDINAL;
temp: INTEGER;
BEGIN
FOR 1:1 TO n-1 DO
FOR j:n TO 11 BY -1 DO IF a[j-1]a[j] THEN
IF a [ j-1 ]a[ j ] THEN
temp:a[j-1];
a[j-1]:a[j];
a[j]:temp
END
END
END
END Algoritmo1;
Solucion

n1 n1
tn   3 5  4  3  4  2 5 3  44n  41
i1 jn

Ejercicio 2
PROCEDURE Algoritmo 2 (VAR a:vector; c: INTEGER): CARDIN. VAR inf, sup, i:

CARDINAL;
BEGIN
inf:1; sup:n;
WHILE (sup-inf) DO
i:(infsup) DIV 2;
IF a[i]c THEN RETURN i
ELSIF ca[i] THEN sup:i-1
ELSE inf:i1
END
END;
RETURN 0;
END Algoritmo2;
Solucion

n
tn  3  1  3  2  4  2 1  12n  4
n1

Ejercicio 3 (Insercion)
Begin
for m  prim1 to ult do
x  a[m] j:m-1
while (jprim) and (xa[j]) do
a[j1]a[j]
end
a[j1]x
end
end

Solucion
n n1
tn   10  4  4 4 3  4n 2  6n  5
i2 ji1

Ejercicio 4 (Burbuja)
Begin
for m prim to ult - 1 do
for j ult to m1 do
I  (a[j-1]  a[j] them
inter (a, j-1, j)
end
end
end
Solucion
n1 n
tn   3 3  4  9 3  3  8n 2  2n  3
i1 ji1

Ejercicio 5 (seleccion)
Begin
for i: prim to ult - 1 do
inter (a,i,posmin (a,i,ult)
End
Solucion
n1
tn  3  737n  7i  1467
2
n2  1461
2
n3
i1

You might also like