1 / 18

Name of the Staff Member : A.Santhosh Kumar Designation : Lecturer

Name of the Staff Member : A.Santhosh Kumar Designation : Lecturer Branch : Computer Engineering Institute : VMR Polytechnic, Rampur, Warangal Semester : III Subject : Data Structures through ‘C’ Subject Code : 9CM305

Download Presentation

Name of the Staff Member : A.Santhosh Kumar Designation : Lecturer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Name of the Staff Member : A.Santhosh Kumar Designation : Lecturer Branch : Computer Engineering Institute : VMR Polytechnic, Rampur, Warangal Semester : III Subject : Data Structures through ‘C’ Subject Code : 9CM305 Topic : Linear Data Structures Duration : 100 Min Sub Topic : Single Linked Circular List Teaching Aids to be used : Power Point Presentation Revised by : Bapuji naik Department of Technical Education Andhra Pradesh 9CM305 .17to18

  2. Recap In the previous lessons, you have learnt How to sort elements in a Linked List • Search ? • Search & replace ? • Reverse ? 9CM305 .17to18

  3. Objectives On compliotion of this e-lesson, you would be able to know. • What is singly linked circular list ? • How to create singly linked circular list ? • Advantages of singly linked circular list ? 9CM305 .17to18

  4. Single Linked List • The collection of node, each node consisting of a data field and a link field to use next node. • Use last node link field contains NULL value because it is not pointing further any other node. 9CM305 .17to18

  5. 10 20 30 40 NULL Disadvantages of S.L.L • Once we move from first node last node we cant traverse • i.e. link field is pointing to use next node ( only forward direction) 9CM305 .17to18

  6. 10 2000 20 30 4000 3000 40 1000 3000 4000 1000 2000 Singly Linked Circular List • A circular list is a list in which the last node link field is pointing to the first node of list • The singly linked circular list is as followes 9CM305 .17to18

  7. Contd… Singly Linked Circular List • In the single linked circular list , the last node link field contains the address of first node • i.e. the last node is pointing to the first node ,to make the linked list circular 9CM305 .17to18

  8. Contd… Singly Linked Circular List • In the S.L.C L ,there is no first node • There is no root node , pointing to the first node • We use dummy header pointing to any node • To know that from where to start • Generally dummy header is also pointing to the first node 9CM305 .17to18

  9. 1000 Contd… Singly Linked Circular List • Example S.L.C.L uses dummy header Dummy header 1000 2000 4000 3000 3000 4000 1000 2000 9CM305 .17to18

  10. Contd… Program to create S.L.C.L Singly Linked Circular List • # include <stdio.h> • # include<conio.h> type def struct linked _list { int info; struct linked _list *link; } NODE ; 9CM305 .17to18

  11. Contd… Singly Linked Circular List main() { NODE* first; char s[50]; int i, ele; NODE*insert(NODE* first,int ele); viod display (NODE* first); clrscr(); Printf(“Enter the long integer \n”); Scanf(“%s”,s); printf(“%s”,s); /*since s is a string of charcters the digits you enter will be in charcter form,substract each digit with character’o’ to get the actual integer. For example ‘2’(ascii value50)-’o’(48)=2*/ 9CM305 .17to18

  12. Contd… Singly Linked Circular List /*insert all the digits into linked list*/ for(i=0;s[i]!=‘\0’;i++) first=insert(first,s[i]-’0’); printf(“\n the elements of the circular linked list”); display(first); } 9CM305 .17to18

  13. Contd… Singly Linked Circular List NODE*insert(NODE*first, int ele) { NODE*new; { new=(NODE*) malloc(size of (NODE); new ->info=ele; if (first->link== first) { first ->link=new; new->link=new; } else { new->link=first->link; first->link=new; } return(first); } 9CM305 .17to18

  14. Contd… Singly Linked Circular List • void display(NODE*first) • { • NODE*temp=first->link; • While(temp !=first) • { • printf(“%d”, temp->info) ; • temp=temp->link; • } • } 9CM305 .17to18

  15. Summary • In the class, we have understood • disadvantages of S.L.L • Singly linked circular list • Creation of S.L.C.L 9CM305 .17to18

  16. Quiz • In the S.L.C.L, the last node link contains 9CM305 .17to18

  17. Assignment • Write a program to insert a new node into the S.L.C.L • Write a program to delete a node from the S.L.C.L • Write a program to search an element in S.C,L.L 9CM305 .17to18

  18. Questions • 1) Explain the advantages of S.L.C.L • 2) Explain the creation of S.L.C.L 9CM305 .17to18

More Related