ICS121 – Data Structures I

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 1 (0s)

ICS121 – Data Structures I. Module 1 Circular Linked List, Doubly Linked List, Doubly Circular Linked List and Applications.

Scene 2 (9s)

Circular Linked List: Representation of Node: struct node.

Scene 3 (20s)

Insertion Operation: Insertion at Beginning: struct node *ptr,*temp; int item; ptr = (struct node *)malloc(sizeof(struct node)); if(ptr == NULL) Write “OVERFLOW"; else { Read item; ptr -> data = item; if(head == NULL) {.

Scene 4 (39s)

Insertion Operation: Insertion at Last:. struct node *ptr,*temp; int item; ptr = (struct node *)malloc(sizeof(struct node)); if(ptr == NULL) Write "OVERFLOW"; else { Read item; ptr->data = item;.

Scene 5 (59s)

Deletion: Deletion at Beginning: struct node *ptr; if(head == NULL) Write "UNDERFLOW"; else if(head->next == head) else {.

Scene 6 (1m 14s)

} else { ptr = head;. Deletion: Deletion at Last: struct node *ptr, *ptr1; while(ptr ->next != head) else if (head ->next == head) ptr1->next = ptr -> next; free(head);.

Scene 7 (1m 27s)

Se. arching:. flag=0; } } if(flag != 0) else Write "Item not found";.

Scene 8 (1m 46s)

Tracing:. struct node *ptr; ptr=head; if(head == NULL) write "nothing to print"; else Write ptr -> data; }.

Scene 9 (1m 58s)

Doubly Linked List: Representation of Node: struct node.

Scene 10 (2m 8s)

Insertion Operation: Insertion at Beginning: struct node *ptr; int item; ptr = (struct node *)malloc(sizeof(struct node)); if(ptr == NULL) write “OVERFLOW"; else { read item; if(head==NULL) { ptr->next = NULL;.

Scene 11 (2m 24s)

Insertion Operation: Insertion at Last: struct node *ptr,*temp; int item; ptr = (struct node *) malloc(sizeof(struct node)); if(ptr == NULL) write "OVERFLOW"; else { Read item; ptr->data=item; if(head == NULL).

Scene 12 (2m 42s)

Insertion Operation: Insertion at random position: struct node *ptr,*temp; Declare item, loc, i; ptr = (struct node *)malloc(sizeof(struct node)); if(ptr == NULL) Write “OVERFLOW"; else { temp=head; Read loc; for(i=0;i<loc;i++).

Scene 13 (3m 1s)

Deletion: Deletion at Beginning: struct node *ptr; if(head == NULL) Write “UNDERFLOW"; else if(head->next == NULL) else {.

Scene 14 (3m 14s)

head = NULL; free(head); } else { ptr = head;. Deletion: Deletion at Last: struct node *ptr; if(ptr->next != NULL) write “UNDERFLOW"; ptr ->prev -> next = NULL; else if(head->next == NULL) free(ptr);.

Scene 15 (3m 27s)

Deletion: Deletion at random: struct node *ptr, *temp; Declare val; Read an item to delete ptr = head; while(ptr -> data != val) ptr = ptr -> next; if(ptr -> next == NULL) Write “No item"; else if(ptr -> next -> next == NULL) { ptr ->next = NULL;.

Scene 16 (3m 47s)

Searching: struct node *ptr; declare item,i=0,flag; ptr = head; if(ptr == NULL) Write “empty list” else { Read search item; while (ptr!=NULL) { if(ptr->data == item) {.

Scene 17 (4m 3s)

Doubly Circular Linked List: Representation of Node: struct node.

Scene 18 (4m 12s)

Insertion Operation: Insertion at Beginning: struct node *ptr,*temp; int item; ptr = (struct node *)malloc(sizeof(struct node)); if(ptr == NULL) Write "OVERFLOW"; else { Read item; ptr->data=item; if(head==NULL) { head = ptr; ptr -> next = head;.

Scene 19 (4m 33s)

Insertion Operation: Insertion at Last:. struct node *ptr,*temp; int item; ptr = (struct node *) malloc(sizeof(struct node)); if(ptr == NULL) Write "OVERFLOW"; else { Read item; ptr->data=item; if(head == NULL).

Scene 20 (4m 53s)

Deletion: Deletion at Beginning: struct node *temp; if(head == NULL) Write " UNDERFLOW"; else if(head->next == head) else {.

Scene 21 (5m 9s)

Deletion: Deletion at Last: struct node *ptr; if(head == NULL) write " UNDERFLOW"; else if(head->next == head) else {.

Scene 22 (5m 24s)

Searching:. struct node *ptr; Int item, i=0,flag=1; ptr = head; if(ptr == NULL) write “Empty List"; else else { while (ptr->next != head).

Scene 23 (5m 43s)

Tracing:. struct node *ptr; ptr=head; if(head == NULL) Write “empty list"; else write ptr -> data; }.

Scene 24 (5m 55s)

Advantage:. Easier to insert or delete data elements Dynamic data structure Memory efficient Implementation Disadvantage: Slow search operation and requires more memory space Backtracking or reverse traversing is difficult. In a doubly linked list, it is easier but requires more memory to store the back pointer. Applications: Implementing stacks, queues, binary trees, and graphs of predefined size. Implement dynamic memory management functions of the operating system. Polynomial implementation for mathematical operations Circular linked list is used to implement OS or application functions that require round-robin execution of tasks. Circular linked list is used in a slide show where a user wants to return to the first slide after the last slide is displayed. Doubly linked list is used in the implementation of forward and backward buttons in a browser to move backward and forward in the opened pages of a website. Circular queue is used to maintain the playing sequence of multiple players in a game..