SlideShare a Scribd company logo
DATA STRUCTURES
Dr. P. Subathra
subathrakishore@yahoo.com
Professor
Dept. of Information Technology
KAMARAJ College of Engineering & Technology
(AUTONOMOUS)
Madurai
Tamil Nadu
India
CS8391 – DATA STRUCTURES
ONLINE CLASSES – CLASS NO. 9
04.09.2020
(10:00 PM – 12:00 Noon)
UNIT 1
CIRCULAR SINGLY LINKED LIST
WHAT IS WRONG WITH
SINGLY LINKED LIST…??
CANNOT REVISIT THE NODES AGAIN IN THE
LIST….???!!!
WHAT IS WRONG WITH
SINGLY LINKED LIST…??
• Is that Annoying….???
• No Worries MAN…!!!
WHAT IS WRONG WITH SINGLY LINKED
LIST…??
CIRCULAR SINGLY LINKED LIST….!!!
Node of a Circular Linked List
• NODE
– Data Field
– Link / Pointer Field
• HEADER…???!!!
• NULL Pointer
SIMILARITY IN BOTH LISTS
1. SINGLY LINKED LIST
2. CIRCULAR SINGLY LINKED LIST
CIRCULAR SINGLY LINKED LIST
MEMORY REPRESENTATION
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
1003
header
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
1003
header
1. 5 Circular singly linked list
Operations on a Singly Circular Linked List
• Creating a new list
• Insertion
- at the beginning
- at the end
- after and element
- before an element
• Deletion
- at the beginning
- at the end
- a given element
- at a position
• Display
• Search Element
• etc ………………
NODE CREATION
CREATING A LIST
• Creating the FIRST Node and Attaching it to
the List
struct node * temp = (node *) malloc (sizeof (struct node));
head = temp;
tempnext = NULL
Operations on a Singly Linked List
NULL
head
Data field Link field
temp1005
Creating a New List
struct node * temp = (node *) malloc (sizeof (struct node));
tempdata =222;
head = temp;
tempnext = head; (or) headnext=head;
1005
head
Data field Link field
1005
temp1005
222
CIRCULAR SINGLY LINKED LIST : CREATING A LIST
INSERT FIRST
1. 5 Circular singly linked list
INSERT LAST
1. 5 Circular singly linked list
DELETE FIRST
1. 5 Circular singly linked list
DELETE LAST
1. 5 Circular singly linked list
POINTS TO NOTE IN CIRCULAR SINGLY LINKED LIST
INSERT LAST
Order of Insertion : 5,6,7, 8
POINTS TO NOTE IN CIRCULAR SINGLY LINKED LIST
INSERT FIRST
Order of Insertion : 5, 6,7, 8
USE A TAIL INSTEAD OF HEAD
USE A TAIL INSTEAD OF HEAD
USE A TAIL INSTEAD OF HEAD
USE A TAIL INSTEAD OF HEAD
void insertLast(int item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
struct node *temp;
temp->next=last;
last=temp;
printf("nNode Inserted Lastn");
}
Circular Singly Linked List: Insert Last
void insertFirst( int item)
{
struct node * temp = (struct node *)malloc(sizeof(struct node));
temp->data=item;
temp->next=last;
printf("nNode Inserted Firstn");
}
Circular Singly Linked List: Insert First
int deleteLast(int item)
{
struct node *temp;
int x= last(x);
temp-=last;
last=last->next;
free (temp);
temp=NULL;
printf("n Deleted Firstn");
return (x);
}
Circular Singly Linked List: Delete First
int deleteLast(int item)
{
struct node *temp; struct node * curr;
If(last==NULL) {Printf(“n no node to delete”);}
Else If(last->next==last)
{ x= last->data; Temp=last; Last=NULL; Free(temp); temp=NULL; return(x) }
Else
{
prev=last;
while(prev->next !=last)
prev=prev->next;
prev->next=last->next;
temp = last; x=last->data;
last= prev;
printf("n Deleted Lastn");
return (x);
}
Circular Singly Linked List: Delete Last

More Related Content

PPT
DS Unit 2.ppt
PPTX
Doubly Circular Linked List1.pptx
PPTX
Binary search tree
PDF
PPT
Data Structures with C Linked List
PPT
1.5 binary search tree
PDF
Binary tree
PPTX
Stack and Queue by M.Gomathi Lecturer
DS Unit 2.ppt
Doubly Circular Linked List1.pptx
Binary search tree
Data Structures with C Linked List
1.5 binary search tree
Binary tree
Stack and Queue by M.Gomathi Lecturer

What's hot (20)

PPT
PPTX
Queue Implementation Using Array & Linked List
PDF
Expression trees
PPTX
Binary Search Tree
PPT
PPSX
Data structure stack&queue basics
PPT
PPTX
Linked list
PPTX
Binary Tree in Data Structure
PPTX
Linked List
PPTX
PPTX
Analysis of Algorithm (Bubblesort and Quicksort)
PPT
Binary search in ds
PPT
Data Structure and Algorithms Binary Search Tree
PPT
Shell sort
PPT
Singly link list
PPTX
The Stack And Recursion
PDF
DSA Lab Manual C Scheme.pdf
PPT
PPTX
Shell sort in Data Structure Using C
Queue Implementation Using Array & Linked List
Expression trees
Binary Search Tree
Data structure stack&queue basics
Linked list
Binary Tree in Data Structure
Linked List
Analysis of Algorithm (Bubblesort and Quicksort)
Binary search in ds
Data Structure and Algorithms Binary Search Tree
Shell sort
Singly link list
The Stack And Recursion
DSA Lab Manual C Scheme.pdf
Shell sort in Data Structure Using C
Ad

Similar to 1. 5 Circular singly linked list (20)

PPTX
Unit 1 LINEAR DATA STRUCTURES
PDF
Singly Linked List
PDF
Unit 1_SLL and DLL.pdf
PDF
Unit 1_Single Linked List and Double Linked List.pdf
PPTX
module 3-.pptx
PPT
Unit ii(dsc++)
PPTX
Unit 5 linked list
PPTX
Linked list
PPTX
linkedlistforslideshare-210123143943.pptx
PPT
Linked list introduction and different operation
PDF
When to NoSQL and when to know SQL
PPTX
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
PPTX
Module 3 Dara structure notes
PDF
Relational database management system
PPTX
Unit II Data Structure 2hr topic - List - Operations.pptx
PPTX
UNIT I LINEAR DATA STRUCTURES – LIST .pptx
PPT
ds 4Linked lists.ppt
Unit 1 LINEAR DATA STRUCTURES
Singly Linked List
Unit 1_SLL and DLL.pdf
Unit 1_Single Linked List and Double Linked List.pdf
module 3-.pptx
Unit ii(dsc++)
Unit 5 linked list
Linked list
linkedlistforslideshare-210123143943.pptx
Linked list introduction and different operation
When to NoSQL and when to know SQL
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
Module 3 Dara structure notes
Relational database management system
Unit II Data Structure 2hr topic - List - Operations.pptx
UNIT I LINEAR DATA STRUCTURES – LIST .pptx
ds 4Linked lists.ppt
Ad

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai (20)

PPTX
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
PPTX
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
PPTX
PDF
PDF
The stable marriage problem iterative improvement method
PDF
Maximum matching in bipartite graphs iterative improvement method
PDF
Knapsack dynamic programming formula top down (1)
PDF
PDF
Multiplication of integers & strassens matrix multiplication subi notes
PDF
Multiplication of large integers problem subi notes
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
The stable marriage problem iterative improvement method
Maximum matching in bipartite graphs iterative improvement method
Knapsack dynamic programming formula top down (1)
Multiplication of integers & strassens matrix multiplication subi notes
Multiplication of large integers problem subi notes

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Well-logging-methods_new................
PPTX
Construction Project Organization Group 2.pptx
PPTX
Artificial Intelligence
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Geodesy 1.pptx...............................................
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
573137875-Attendance-Management-System-original
PPTX
Internet of Things (IOT) - A guide to understanding
CYBER-CRIMES AND SECURITY A guide to understanding
Embodied AI: Ushering in the Next Era of Intelligent Systems
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Automation-in-Manufacturing-Chapter-Introduction.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Well-logging-methods_new................
Construction Project Organization Group 2.pptx
Artificial Intelligence
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Geodesy 1.pptx...............................................
Mechanical Engineering MATERIALS Selection
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Foundation to blockchain - A guide to Blockchain Tech
573137875-Attendance-Management-System-original
Internet of Things (IOT) - A guide to understanding

1. 5 Circular singly linked list

  • 1. DATA STRUCTURES Dr. P. Subathra [email protected] Professor Dept. of Information Technology KAMARAJ College of Engineering & Technology (AUTONOMOUS) Madurai Tamil Nadu India
  • 2. CS8391 – DATA STRUCTURES ONLINE CLASSES – CLASS NO. 9 04.09.2020 (10:00 PM – 12:00 Noon)
  • 4. WHAT IS WRONG WITH SINGLY LINKED LIST…??
  • 5. CANNOT REVISIT THE NODES AGAIN IN THE LIST….???!!! WHAT IS WRONG WITH SINGLY LINKED LIST…??
  • 6. • Is that Annoying….??? • No Worries MAN…!!! WHAT IS WRONG WITH SINGLY LINKED LIST…??
  • 8. Node of a Circular Linked List • NODE – Data Field – Link / Pointer Field • HEADER…???!!! • NULL Pointer
  • 9. SIMILARITY IN BOTH LISTS 1. SINGLY LINKED LIST 2. CIRCULAR SINGLY LINKED LIST
  • 12. 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
  • 13. 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1003 header
  • 14. 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1003 header
  • 16. Operations on a Singly Circular Linked List • Creating a new list • Insertion - at the beginning - at the end - after and element - before an element • Deletion - at the beginning - at the end - a given element - at a position • Display • Search Element • etc ………………
  • 18. CREATING A LIST • Creating the FIRST Node and Attaching it to the List struct node * temp = (node *) malloc (sizeof (struct node)); head = temp; tempnext = NULL Operations on a Singly Linked List NULL head Data field Link field temp1005
  • 19. Creating a New List struct node * temp = (node *) malloc (sizeof (struct node)); tempdata =222; head = temp; tempnext = head; (or) headnext=head; 1005 head Data field Link field 1005 temp1005 222 CIRCULAR SINGLY LINKED LIST : CREATING A LIST
  • 28. POINTS TO NOTE IN CIRCULAR SINGLY LINKED LIST INSERT LAST Order of Insertion : 5,6,7, 8
  • 29. POINTS TO NOTE IN CIRCULAR SINGLY LINKED LIST INSERT FIRST Order of Insertion : 5, 6,7, 8
  • 30. USE A TAIL INSTEAD OF HEAD
  • 31. USE A TAIL INSTEAD OF HEAD
  • 32. USE A TAIL INSTEAD OF HEAD
  • 33. USE A TAIL INSTEAD OF HEAD
  • 34. void insertLast(int item) { struct node *temp = (struct node *)malloc(sizeof(struct node)); struct node *temp; temp->next=last; last=temp; printf("nNode Inserted Lastn"); } Circular Singly Linked List: Insert Last
  • 35. void insertFirst( int item) { struct node * temp = (struct node *)malloc(sizeof(struct node)); temp->data=item; temp->next=last; printf("nNode Inserted Firstn"); } Circular Singly Linked List: Insert First
  • 36. int deleteLast(int item) { struct node *temp; int x= last(x); temp-=last; last=last->next; free (temp); temp=NULL; printf("n Deleted Firstn"); return (x); } Circular Singly Linked List: Delete First
  • 37. int deleteLast(int item) { struct node *temp; struct node * curr; If(last==NULL) {Printf(“n no node to delete”);} Else If(last->next==last) { x= last->data; Temp=last; Last=NULL; Free(temp); temp=NULL; return(x) } Else { prev=last; while(prev->next !=last) prev=prev->next; prev->next=last->next; temp = last; x=last->data; last= prev; printf("n Deleted Lastn"); return (x); } Circular Singly Linked List: Delete Last