Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Un TAD es un tipo de dato definido por el programador. Los tipos abstractos de datos estn
formados por los datos (estructuras de datos) y las operaciones (procedimientos o funciones)
que se realizan sobre esos datos.
Una propiedad importante de la lista es que sus elementos estn ordenados en forma lineal, es
decir, para cada elemento ai existe un sucesor ai+1 (si i < n - 1) y un predecesor ai+1 (si i
> 0).
Dos listas son iguales si tienen los mismos elementos y en el mismo orden.
(1; 3; 7; 4) (3; 7; 4; 1)
Desventajas
La eliminacin e insercin de elementos toma mucho tiempo
Se debe conocer el tamao mximo del arreglo y este no se puede modificar luego de indicado.
Algoritmo:
1) Add(value)
2) Pre: value is the value to add to the list
3) Post: value has been placed at the tail of the list
4) n node(value)
5) if head =
6) head n
7) tail n
8) else
9) tail.Next n
10) tail n
11) end if
12) end Add
Algoritmo:
1) Contains(head, value)
2) Pre: head is the head node in the list
3) value is the value to search for
4) Post: the item is either in the linked list, true; otherwise false
5) n head
6) while n and n.Value value
7) n n.Next
8) end while
9) if n =
10) return false
11) end if
12) return true
13) end Contains
Algoritmo:
1) Traverse(head)
2) Pre: head is the head node in the list
3) Post: the items in the list have been traversed
4) n head
5) while n 0
6) yield n.Value
7) n n.Next
8) end while
9) end Traverse
//auto referencia
private Nodo enlace;
public Nodo()
{
this.dato = 0;
this.enlace = null;
}
public Lista()
{
this.primero = null;
this.ultimo = null;
}
Nodo nuevo;
nuevo = new Nodo(dato);
if (primero == null)
{
primero = nuevo;
ultimo = nuevo;
}
else
{
nuevo.setEnlace(primero);
primero = nuevo;
}
if (primero == null)
{
primero = nuevo;
ultimo = nuevo;
}
else
{
ultimo.setEnlace(nuevo);
ultimo = nuevo;
}
}
p = p.getEnlace();
}
return encontro;
}
if(primero.getEnlace() == null)
{
primero = null;
ultimo = null;
return false;
}
else
{
Nodo temp = primero;
primero = primero.getEnlace();
temp.setEnlace(null);
return true;
}
}
if(!esVacia())
{
Nodo p = primero;
while(p.getEnlace() != null)
{
str += p.getDato() + " ";
p = p.getEnlace();
}
}
else
{ str = "Lista Vacia"; }
return str;
}
}
B. En la lista enlazada solo deberamos cambiar tres enlaces: hacer que el nodo T apunte a A, el nodo S
apunte a Z y la cabecera apunte a T.
1. Crear lista
2. Imprimir lista
3. Anexar nodos Inicio
4. Anexar nodos final
5. Buscar nodos
6. Borrar nodo inicio
7. Borrar nodo final
8. Salir";
Algoritmo:
1) Add(value)
2) Pre: value is the value to add to the list
3) Post: value has been placed at the tail of the list
4) n node(value)
5) if head =
6) head n
7) tail n
8) else
9) n.Previous tail
10) tail.Next n
11) tail n
12) end if
13) end Add
// Mtodos
// ...
}