FACULTAD DE INGENIERA
Algoritmos y Estructura
de Datos II
ARREGLOS UNIDIMENSIONALES
Donde estamos?
Qu ventajas y
desventajas encuentra a
los arreglos?
Qu tipos de datos
conocemos hasta ahora?
Con qu tipo de
variables hemos
trabajado?
Podemos estructurar,
clasificar a los tipos de
datos estudiados?
Entero
Real
Estndar
Carcter
Simples
Lgico
Definidos por el
programador
Enumerativos
Arrays
Datos
Registros
Estticos
Ficheros
Conjuntos
Cadenas
Estructurados
Listas
Listas enlazadas
Dinmicos
rboles
Grafos
Cmo lo soluciono?
Qu pasara si el
profesor nos plantea
generar una nota
aleatoria para cada
estudiante de la clase
(30), cuntos serian los
aprobados, jalados,
nota mxima, mnima y
promedio?
Logro Esperado
Al finalizar la sesn, el
estudiante presenta un
solucionario de
ejercicios propuestos
sobre arreglos
unidimensionales,
documentando para
cada uno su solucin
propuesta
ARREGLOS UNIDIMENSIONALES
Introduccin
Terminologa bsica
TipoElemento[ ] id ;
Ejemplo
Definiciones
char[] c;
int[] value = new int[10];
Descripcin
La variable c que es un arreglo de objetos no esta inicializada
La variable value que es un arreglo de objetos hace referencia a
una nueva lista de 10 elementos del tipo entero
Cada uno de los enteros es inicializado por defecto en 0
c
value
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
12
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
Se muestra 8
12
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
int[] v = new int[10];
int i = 7;
int j = 2;
int k = 4;
v[0] = 1;
v[i] = 5;
v[j] = v[i] + 3;
v[j+1] = v[i] + v[0];
v[v[j]] = 12;
System.out.println(v[2]);
v[k] = stdin.nextInt();
v
12
v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]
Considere
cdigo
int[] b = new int[100];
b[-1] = 0;
b[100] = 0;
ocasiona
Se crea una variable array b que hace referencia a una
nueva lista de 100 enteros
Cada elemento es inicializado en cero
Solucin al problema
Qu pasara si el profesor
nos plantea generar una nota
aleatoria para cada
estudiante de la clase (30),
cuntos serian los
aprobados, jalados, nota
mxima, mnima y
promedio?
PREGUNTAS DE REPASO
Qu hemos aprendido?
Recordando la clase
Qu es un arreglo y qu
tipos conocemos?
Qu tipo de dato es un
vector de acuerdo a la
clasificacin estudiada?
Cundo uso un vector?
Cmo definimos un
vector?
Un vector es una variable o
una referencia? Explique
Describa el cdigo usado
para leer, generar y mostrar
un vector cualquiera.
Qu es un mtodo?
APLICACIN PRCTICA
Problema propuesto
Leer por consola n
nombres y contar la
cantidad de veces que
se ha usado cada letra
del abecedario. No
considerar los
caracteres , , , , ,