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

What's hot (20)

PPT
Unit 3 graph chapter6
DrkhanchanaR
 
PPTX
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
PPTX
Stack Data Structure
Afaq Mansoor Khan
 
PPTX
Counting Sort
Faiza Saleem
 
PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PPTX
Linklist
SHEETAL WAGHMARE
 
PPTX
Link_List.pptx
sandeep54552
 
PDF
Singly linked list
Amar Jukuntla
 
PPTX
Stack & Queue using Linked List in Data Structure
Meghaj Mallick
 
PPT
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
PPTX
Linear data structure concepts
Akila Krishnamoorthy
 
PPTX
linked list using c
Venkat Reddy
 
PPTX
AVL Tree Data Structure
Afaq Mansoor Khan
 
PDF
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
PPTX
Unit 2 linked list
DrkhanchanaR
 
PPTX
Doubly Linked List
Ninad Mankar
 
PPT
C pointers
Aravind Mohan
 
PPSX
Data Structure (Tree)
Adam Mukharil Bachtiar
 
PPTX
Threaded Binary Tree.pptx
pavankumarjakkepalli
 
PPT
3.6 radix sort
Krish_ver2
 
Unit 3 graph chapter6
DrkhanchanaR
 
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Stack Data Structure
Afaq Mansoor Khan
 
Counting Sort
Faiza Saleem
 
Priority Queue in Data Structure
Meghaj Mallick
 
Link_List.pptx
sandeep54552
 
Singly linked list
Amar Jukuntla
 
Stack & Queue using Linked List in Data Structure
Meghaj Mallick
 
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
Linear data structure concepts
Akila Krishnamoorthy
 
linked list using c
Venkat Reddy
 
AVL Tree Data Structure
Afaq Mansoor Khan
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
Unit 2 linked list
DrkhanchanaR
 
Doubly Linked List
Ninad Mankar
 
C pointers
Aravind Mohan
 
Data Structure (Tree)
Adam Mukharil Bachtiar
 
Threaded Binary Tree.pptx
pavankumarjakkepalli
 
3.6 radix sort
Krish_ver2
 

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

PPTX
Data structures2
Parthipan Parthi
 
PDF
Circular linked list
maamir farooq
 
PDF
Document on Linked List as a presentation
bindiyap3
 
PDF
Document on Linked List as a presentation
bindiyap3
 
PPTX
Deleting a node from the list(SINGLE LINKED LIST)
JayasankarShyam
 
PPTX
DS-3asdfghjklxmmcnaefiuhavbifuhablc.pptx
DRCARIBOU
 
PPTX
Linked List in Data Structure
Meghaj Mallick
 
PPTX
Circular linked list.pptx
Santhiya S
 
PPTX
LINKED LIST.pptx
ManojUniversity
 
PPTX
UNIT -4 Singly Linked List-kiruthika.pptx
kiruthikancse
 
PPTX
Linked list using Dynamic Memory Allocation
kiran Patel
 
PPTX
Linked Lists, Single Linked list and its operations
BackiyalakshmiVenkat
 
PPTX
linkedlistforslideshare-210123143943.pptx
shesnasuneer
 
PPTX
module 3-.pptx
kumarkaushal17
 
PPTX
dokumen.tips_linked-list-ppt-5584a44be6115.pptx
MrMudassir
 
PPTX
Linked list
KalaivaniKS1
 
PPTX
Data structure.pptx
SajalFayyaz
 
PPTX
linkedlist.pptx
MeghaKulkarni27
 
PPT
Circular_Linked_List.ppt
SLekshmiNair
 
PDF
Singly Linked List
raghavbirla63
 
Data structures2
Parthipan Parthi
 
Circular linked list
maamir farooq
 
Document on Linked List as a presentation
bindiyap3
 
Document on Linked List as a presentation
bindiyap3
 
Deleting a node from the list(SINGLE LINKED LIST)
JayasankarShyam
 
DS-3asdfghjklxmmcnaefiuhavbifuhablc.pptx
DRCARIBOU
 
Linked List in Data Structure
Meghaj Mallick
 
Circular linked list.pptx
Santhiya S
 
LINKED LIST.pptx
ManojUniversity
 
UNIT -4 Singly Linked List-kiruthika.pptx
kiruthikancse
 
Linked list using Dynamic Memory Allocation
kiran Patel
 
Linked Lists, Single Linked list and its operations
BackiyalakshmiVenkat
 
linkedlistforslideshare-210123143943.pptx
shesnasuneer
 
module 3-.pptx
kumarkaushal17
 
dokumen.tips_linked-list-ppt-5584a44be6115.pptx
MrMudassir
 
Linked list
KalaivaniKS1
 
Data structure.pptx
SajalFayyaz
 
linkedlist.pptx
MeghaKulkarni27
 
Circular_Linked_List.ppt
SLekshmiNair
 
Singly Linked List
raghavbirla63
 
Ad

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

PPTX
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PPTX
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PPTX
1. C Basics for Data Structures Bridge Course
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Optimal binary search tree dynamic programming
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
The stable marriage problem iterative improvement method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Maximum matching in bipartite graphs iterative improvement method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Knapsack dynamic programming formula top down (1)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Knapsack dynamic programming formula bottom up
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Multiplication of integers & strassens matrix multiplication subi notes
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PDF
Multiplication of large integers problem subi notes
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
The stable marriage problem iterative improvement method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Maximum matching in bipartite graphs iterative improvement method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Knapsack dynamic programming formula top down (1)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Multiplication of integers & strassens matrix multiplication subi notes
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Multiplication of large integers problem subi notes
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Ad

Recently uploaded (20)

PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 

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