Está en la página 1de 10

Definiciones de LISTA

“Lista o secuencia es una colección homogénea de


datos, ordenados según su posición en ella, tal que
cada elemento tiene un predecesor (excepto el
primero) y un sucesor (excepto el ultimo)”
[Estructura de Datos y Algoritmos]

“Una lista enlazada es una estructura de datos en la


cual los objetos están organizados linealmente”

Prog. 2 - 2022 1
Listas

“Dado un conjunto A y A* el conjunto de


elementos encadenados o en secuencia de A,
llamamos una lista generalizada L ε A*, a una
secuencia finita de n>=0 elementos a1, ............
an , donde ai es un elemento átomo. Si ai es una
lista entonces se llama sublista de L. Si n>= 1,
entonces a1 se dice la cabeza de L y el resto la
cola”

Prog. 2 - 2022 2
ESPECIFICACIÓN SINTACTICA
LISTA

Estructura LISTA(L)
CREAR()→ Lista
AGREGAR_ITEM(lista, item) → Lista
AGREGAR_LISTA(lista, lista) → lista
BORRAR_ITEM(lista, item) → lista
BORRAR_LISTA(lista, lista) → lista
CABEZA_ITEM(lista) → item
CABEZA_LISTA(lista) → lista
ESTA_VACIA (lista) → boolean
IGUAL(lista, lista) → boolean

Prog. 2 - 2022 3
ESPECIFICACIÓN SEMANTICA
LISTA GENERALIZADA
Para todo l, l1,l2,l3 ε A*, i, i1 ε A

ESTA_VACIA (CREAR()) ::= true

ESTA_VACIA (AGREGAR_ITEM(l, i)) ::= false

ESTA_VACIA (AGREGAR_LISTA(l, l1)) ::= false

IGUAL (CREAR(), l) ::= ESTA_VACIA (l)

IGUAL (l,CREAR()) ::= ESTA_VACIA(l)

IGUAL( AGREGAR_ITEM(l, i), AGREGAR_ITEM (l1, i1)) ::= if i = i1 then


IGUAL(l, l1) else false

IGUAL(AGREGAR_ITEM(l, i),AGREGAR_LISTA l1, l2) ::= false

IGUAL(AGREGAR_LISTA(l, l1),AGREGAR_ITEM(l2, i)) ::= false


Prog. 2 - 2022 4
ESPECIFICACIÓN SEMANTICA
LISTA GENERALIZADA (cont.)

IGUAL(AGREGAR_LISTA(l, l1),AGREGAR_LISTA(l2, l3)) ::= IGUAL(l, l2) AND


IGUAL(l1, l3)

CABEZA_ITEM(CREAR()) ::= error

CABEZA_ ITEM(AGREGAR_ITEM(l, i)) ::= if ESTA_VACIA (l) then i else


CABEZA_ITEM(l)

CABEZA_ITEM(AGREGAR_LISTA(l, l1)) ::= if ESTA_VACIA (l) then error else


CABEZA_ITEM(l)

CABEZA_LISTA(CREAR()) ::= error

CABEZA_LISTA(AGREGAR_ITEM(l, i)) ::= if LISTA_VACIA (l) then error else


CABEZA_LISTA(l)

CABEZA_LISTA(AGREGAR_LISTA(l, l1)) ::= if ESTA_VACIA (l) then l1 else


CABEZA_LISTA(l)
Prog. 2 - 2022 5
ESPECIFICACIÓN SEMANTICA
LISTA GENERALIZADA (cont.)
BORRAR_ITEM(CREAR(), i) ::= CREAR()

BORRAR_ITEM(AGREGAR_ITEM(l, i), i1) ::= if i = i1 then BORRAR_ITEM(l,i1) else


AGREGAR_ITEM(BORRAR_ITEM(l, i1), i)

BORRAR_ITEM(AGREGAR_LISTA(l, l1), i) ::=


AGREGAR_LISTA(BORRAR_ITEM(l,i),BORRAR_ITEM(l1, i))

BORRAR_LISTA(CREAR(), l) ::= CREAR()

BORRAR_LISTA(AGREGAR_ITEM(l, i), l1) ::= AGREGAR_ITEM(BORRAR_LISTA(l, l1), i)

BORRAR_LISTA(AGREGAR_LISTA(l, l1), l2) ::= if IGUAL(l1, l2) then


BORRAR_LISTA(l, l2) else
Prog. 2 - 2022 AGREGAR_LISTA(BORRAR_LISTA(l, l2), BORRAR_LISTA(l1, l2)) 6
PILAS
“Una pila es un TDA dinámico homogéneo al que solo se tiene
acceso por la cabeza o cima de la pila (Tope); dicho acceso es del
tipo LIFO (Last Int – First Out).”

Estructura PILA(S)
dado pila = P*, elemento ε P
CREAR()→ pila
AGREGAR(pila, elemento) → pila
BORRAR(pila) → pila
TOPE(pila) → elemento
ESTA_VACIA (pila) → boolean

Para todo p ε P*, a ε P


ESTA_VACIA (CREAR()) ::= true
ESTA_VACIA (AGREGAR(p, a)) ::= false
TOPE(CREAR()) ::= error
TOPE(AGREGAR(p, a)) ::= a
BORRAR(CREAR()) ::= CREAR()
BORRAR(AGREGAR(p, a)) ::= p
Prog. 2 - 2022 7
COLAS
“Una cola es un TDA dinámico homogéneo con acceso del tipo
FIFO (First Int – First Out), al que se tiene acceso al principio de
la cola para sacar elementos, y al final para agregarlos.”
Estructura COLA(S)
dado cola = C* and elemento ε C
CREAR()→ cola
AGREGAR(cola, elemento) → cola
BORRAR(cola) → cola
FRENTE(cola) → elemento
ESTA_VACIA (cola) → boolean
Para todo c ε C*, a ε C
ESTA_VACIA (CREAR()) ::= true
ESTA_VACIA (AGREGAR(c, a)) ::= false
FRENTE(CREAR()) ::= error
FRENTE(AGREGAR(c, a)) ::= if ESTA_VACIA(c) then a else FRENTE(c)
BORRAR(CREAR()) ::= CREAR()
BORRAR(AGREGAR(c, a)) ::= if ESTA_VACIA(c) then CREAR()
else AGREGAR(BORRAR(c),a)
Prog. 2 - 2022 8
Estructura de datos

“Es la representación de un TDA que combina los


constructores de tipo y los tipos predefinidos habituales en los
lenguajes de programación ”

Una estructura de datos puede ser definida como una tripla


compuesta de:
1. una estructura referencial
2. un tipo de datos
3. un mapeamiento desde el conjunto de nombres simbólicos
de las relaciones al conjunto de objetos del tipo de datos

Prog. 2 - 2022 9
IMPLEMENTACION MEDIANTE UN LENGUAJE

Estructura Tipo Abstracto de Datos


Referencial

Estructura de Operaciones
Datos

Estructura Tipos de Datos


Referencial Primitivos

Valores Operaciones

Prog. 2 - 2022 10

También podría gustarte