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
PPT
linked list
PPTX
Linked List
PPTX
Queues in C++
PPTX
Stack, Queue, Linked List.pptx
PPTX
Doubly linked list (animated)
PPTX
Doubly & Circular Linked Lists
DS Unit 2.ppt
linked list
Linked List
Queues in C++
Stack, Queue, Linked List.pptx
Doubly linked list (animated)
Doubly & Circular Linked Lists

What's hot (20)

PPTX
Joins And Its Types
PPT
Chapter 1( intro & overview)
PPT
358 33 powerpoint-slides_8-linked-lists_chapter-8
PPTX
Linked list
PPT
Sql – Structured Query Language
PDF
Laravel 101
PPTX
Doubly linked list
PPTX
PPTX
Binary tree and operations
PPT
DATA STRUCTURES
PPT
Quick Sort
PDF
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
PPTX
Linked List
PPTX
Ppt on Linked list,stack,queue
DOC
Plsql task answers
PPT
Stacks, Queues, Deques
PPTX
Introduction to data structure
PPTX
Stack data structure in Data Structure using C
PPT
Stacks & Queues
PDF
linked lists in data structures
Joins And Its Types
Chapter 1( intro & overview)
358 33 powerpoint-slides_8-linked-lists_chapter-8
Linked list
Sql – Structured Query Language
Laravel 101
Doubly linked list
Binary tree and operations
DATA STRUCTURES
Quick Sort
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List
Ppt on Linked list,stack,queue
Plsql task answers
Stacks, Queues, Deques
Introduction to data structure
Stack data structure in Data Structure using C
Stacks & Queues
linked lists in data structures
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
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Well-logging-methods_new................
PPTX
Lecture Notes Electrical Wiring System Components
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
web development for engineering and engineering
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Geodesy 1.pptx...............................................
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
R24 SURVEYING LAB MANUAL for civil enggi
OOP with Java - Java Introduction (Basics)
Well-logging-methods_new................
Lecture Notes Electrical Wiring System Components
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
web development for engineering and engineering
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx

1. 5 Circular singly linked list

  • 1. DATA STRUCTURES Dr. P. Subathra subathrakishore@yahoo.com 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