Descargar la presentación
La descarga está en progreso. Por favor, espere
Publicada porCésar Balcazar Modificado hace 9 años
1
Listas Ligadas1UVM Listas Ligadas
2
2UVM
3
Listas Ligadas3UVM 5.1 Objetivos El estudiante manejará el tad Lista Ligada, sobre memoria estática
4
Listas Ligadas4UVM 5.2 Temas a Cubrir Definición Pila Ligada Cola Ligada Lista Ligada Lista Doblemente Ligada
5
Listas Ligadas5UVM 5.3 Definición Una lista es una colección de elementos ordenada de acuerdo a las posiciones de éstos (secuencia, relación predecesor-sucesor)
6
Listas Ligadas6UVM 5.4 Pila Ligada
7
Listas Ligadas7UVM # include struct node { int data; struct node *link; };
8
Listas Ligadas8UVM struct node *push(struct node *p, int value) { struct node *temp; temp=(struct node *)malloc(sizeof(struct node)); if(temp==NULL) { printf("No Memory available Error\n"); exit(0); } temp->data = value; temp->link = p; p = temp; return(p); }
9
Listas Ligadas9UVM struct node *pop(struct node *p, int *value) { truct node *temp; if(p==NULL) { printf(" The stack is empty can not pop Error\n"); exit(0); } *value = p->data; temp = p; p = p->link; free(temp); return(p); }
10
Listas Ligadas10UVM 5.5 Cola Ligada
11
Listas Ligadas11UVM # include struct node { int data; struct node *link; };
12
Listas Ligadas12UVM void insert(struct node **front, struct node **rear, int value) { struct node *temp; temp=(struct node *)malloc(sizeof(struct node)); /* creates new node using data value passed as parameter */ if(temp==NULL) { printf("No Memory available Error\n"); exit(0); } temp->data = value; temp->link=NULL; if(*rear == NULL) { *rear = temp; *front = *rear; } else { (*rear)->link = temp; *rear = temp; }
13
Listas Ligadas13UVM void delete(struct node **front, struct node **rear, int *value) { struct node *temp; if((*front == *rear) && (*rear == NULL)) { printf(" The queue is empty cannot delete Error\n"); exit(0); } *value = (*front)->data; temp = *front; *front = (*front)->link; if(*rear == temp) *rear = (*rear)->link; free(temp); }
14
Listas Ligadas14UVM 5.6 Lista Ligada # include struct node { int info; struct node *next; } ; typedef struct node *NODEPTR;
15
Listas Ligadas15UVM NODEPTR getnode() { NODEPTR p; p = (NODEPTR) malloc(sizeof(struct node)); return(p); } void freenode(NODEPTR p) { free(p); }
16
Listas Ligadas16UVM void insafter(NODEPTR p, int x) { NODEPTR q; if (p == NULL) { printf("insercion nula\n"); exit(1); } q = getnode(); q -> info = x; q -> next = p -> next; p -> next = q; }
17
Listas Ligadas17UVM void insend(NODEPTR *plist, int x) { NODEPTR p,q; p = getnode(); p->info = x; p->next = NULL; if (*plist == NULL) *plist = p; else { for (q = *plist; q->next != NULL; q = q->next) ; q->next = p; }
18
Listas Ligadas18UVM void delafter(NODEPTR p, int *px) { NODEPTR q; if ((p == NULL) || (p -> next == NULL)) { printf("remocion nula\n"); exit(1); } q = p ->next; *px = q -> info; p -> next = q -> next; freenode(q); }
19
Listas Ligadas19UVM NODEPTR search(NODEPTR list, int x) { NODEPTR p; for (p = list; p != NULL; p = p->next) if (p->info == x) return (p); return (NULL); }
20
Listas Ligadas20UVM 5.6 Lista Doblemente Ligada
21
Listas Ligadas21UVM Tarea #5 (entrega 28 Marzo 2009) Escriba un programa en C que solicite una expresión aritmética que use varios paréntesis y que, por medio de una pila ligada, verifique si la expresión ttiene el mismo número de paréntesis abiertos que cerrados.
22
Listas Ligadas22UVM
Presentaciones similares
© 2024 SlidePlayer.es Inc.
All rights reserved.