2. Las cosas mejores y más bellas del mundo no se
pueden ver ni tocar, se deben sentir con el corazón.
Helen Keller
3. Objetivo
1. Adquirir los conceptos
básicos relacionados con
las EDD
2. Reconocer las
características de las
EDD
● 2.2 Operaciones de búsqueda
y clasificación
Contenido
5. ○ CONSIDERACIONES GENERALES
■ Estructura dinámica crece con la necesidad, no tiene tamaño
predefinido.
■ Es necesario crear un nodo con dos partes:
● Info = Información
● R = Referencia a próximo nodo
■ Es necesario una referencia al primer elemento de la lista, si
L es vacía la referencia es “null”.
■ La referencia del último nodo de L es a “null”
LISTAS utilizando REFERENCIAS
Info rr
6. ○ CONSIDERACIONES DE METODOS
■ Makenull(L)
● Actualiza la referencia L a null
■ Insert(L, p, e)
● Crea un nuevo nodo, actualiza elemento e y actualiza
las referencias
■ Delete(L, p)
● Determina el nodo p a eliminar, actualiza referencias.
■ Print(L)
LISTAS utilizando REFERENCIAS
7. ‘H’ rr
‘O’ rs
‘L’ rnull
LISTA L
Lista implementada con referencias
referencias
Información tipo char
8. ○ Ejemplo de implementación:
■ listaRnodo.java
● Implementación del nodo para listas referenciadas
■ listaR.java
● Implementación de los métodos básicos de listas utilizando
referencias.
■ listaRprincipal.java
● Menú de interacción con el usuario para que realice los
métodos de listas.
Implementación LISTAS - referencias
13. Listas implementadas con CURSORES
○ DEFINICIONES
■ Se necesita dos arreglos paralelos por lista L
● El primer arreglo contiene la información y
● El segundo arreglo contiene la dirección del siguiente
elemento
■ Un cursor es el índice del próximo elemento
■ El inicio es un cursor (0..99)
■ El fin de lista es un cursor con valor -1
15. LISTAS con cursores
■ FIRST(L) Es un entero (1..9999)
■ END(L) Es un entero negativo (0 def)
■ MAKENULL(L) L = -1
■ INSERT(L,p,e) cambia cursor a nuevo elemento
■ DELETE(L,p) cursor salta un elemento
■ NEXT(L,p) elemento apuntado por p
■ PREVIOUS(L,p) elemento apuntado por p-1
■ LOCATE(L,e) devuelve p si primera ocurrencia
■ RETRIEVE(L,p) devuelve ele si existe p
■ PRINT(L) Imprime elementos de lista L
16. ○ Field Summary
■ Fields inherited from class java.util.AbstractListmodCount
○ Constructor Summary
■ LinkedList()
Constructs an empty list.
■ LinkedList(Collection c)
Constructs a list containing the elements of the specified
collection, in the order they are returned by the collection's
iterator.
Java Class LinkedList
17. ○ Method Summary
■ Void
● add(int index, Object element)
Inserts the specified element at the specified position in this
list.
■ Boolean
● add(Object o)
Appends the specified element to the end of this list.
■ Boolean
● addAll(Collection c)
Appends all of the elements in the specified collection to the
end of this list, in the order that they are returned by the
specified collection's iterator.
Class LinkedList Metodos
18. ○ Void
■ addFirst(Object o)
Inserts the given element at the beginning of this list.
○ Void
■ addLast(Object o)
Appends the given element to the end of this list.
○ Void
■ clear()
Removes all of the elements from this list.
■ Objectclone()
Returns a shallow copy of this LinkedList.
Class LinkedList Metodos 2
20. ○ FUNCION DEPURAR
○ OBJETIVO
■ Dada una lista L, eliminar elementos cuyos valores
sean duplicados y compactar la lista.
○ RESULTADO
■ Devolver la lista L compacta y sin elementos
duplicados
○ ALGORITMO
LISTAS : operaciones avanzadas
21. LISTAS : función depurar
○ DEPURAR ( LISTA L);
○ var p,q : posición
○ start
■ P = FIRST(L)
■ while p < > END(L)
● Q = NEXT(L);
● while q < > END(L)
● if RETRIEVE(p,L) = RETRIEVE(q,L)
● then DELETE(q,L)
22. LISTAS : funciones avanzadas
○ FUNCION IGUAL
○ OBJETIVO
■ Dada una lista L, y dos posiciones, determinar si
son o no iguales
○ RESULTADO
■ Devolver TRUE si son iguales y FALSE si son
desiguales
○ ALGORITMO
23. LISTAS : función igual
○ IGUAL ( LISTA L, p, q, RES);
○ VAR p,q : posición
○ start
■ X = retrieve(L, p)
■ Y = retrieve (L,q)
■ if X=Y then RES = TRUE
■ else RES = FALSE
24. EJERCICIO listas - cursores
○ Sea:
■ L, M, N listas y un arreglo de 10 elementos
○ Determine el valor del arreglo en c/caso
■ Makenull(L) Insert(N, 2, C)
■ Insert(L, 10, A) Insert(N, 1, X)
■ Insert(M, 7, X) Delete(L, 2)
■ Insert(L, 8, B) Makenull(M)
■ Delete(M, 1) Insert(L, 1, Y)
■ Makenull(N) Insert(L, 1, A)