SlideShare a Scribd company logo
Data Structures
Linked List
Linkedlist:
 Linkedlist is a linear collections of nodes.
 Node: A node contains 2 fields.
 data item / information
 Null/ Address of the next node.
Linkedlist representation:
Struct node{
int item;
struct node *next;
};
Allocation of memory to a node:
 Struct node *temp;
 Temp=(struct node*) malloc (sizeof(struct node));
 Temp is a node type pointer variable it can
points to dynamic allocated memory.
Accessing the temp:
 Temp can be accessed by using the following
code.
temp->item= data
temp->next= null / address of the next node
Example of linkedlist
Struct node *start;
start=(struct node*) malloc (sizeof(struct node));
Operations on linked list:
 Creation.
 Insertion.
 Deletion.
 Traversing.
 Searching.
Insertion:
 At the beginning of the linkedlist.
 In the middle of the linkedlist.
 At the end of the linkedlist.
Insertion at Beginning:
To do so we have to follow the following code.
Newnode= (struct node *)malloc(sizeof(struct node);
Scanf(“%d”,&newnode->data);
Newnode->next=NULL;
Newnode
creation
Insertion at Beginning:
Inserting at the
begining
Head->next= newnode;
newnode =head;
Newnode
creation
Insertion at middle:
We have to go to the before position where we wanted to insert
the n ode.
for(i=1;i< pos -1;i++)
temp =temp ->next;
Newnode= (struct node *)malloc(sizeof(struct
node);
Scanf(“%d”,&newnode->data);
Newnode->next=NULL;
Newnode
creation
Insertion at middle:
After we reached before position where we wanted to insert the
node.
Newnode ->next = Temp ->next;
Temp ->next= newnode;
Insert node
in
the specified
position
Insertion at end:
We have to go to the end position where we wanted to insert the n
ode.
while (temp ->next!=NULL)
temp=temp->next;
Newnode= (struct node *)malloc(sizeof(struct
node);
Scanf(“%d”,&newnode->data);
Newnode->next=NULL;
Newnode
creation
Insertion at end:
Temp ->next= newnode;
Insert node
in
the specified
position
Deletion:
 At the beginning of the linkedlist.
 In the middle of the linkedlist.
 At the end of the linkedlist.
Deletion at Beginning:
We have to delete the first node in the
linked list.
head = head ->next
Deletion
of
First node
Deletion at middle:
Moving to
specific
node
We have to go to the before position where we wanted to insert
the n ode.
for(i=1;i<pos-1;i++)
temp = temp ->next;
Deletion at middle:
Deletion
the node
Deleting the specific node.
newnode -> next= temp ->next;
temp -> next = newnode;
Deletion at the end:
Moving to
last nut one
node
We have to go to the before position where we wanted to insert
the n ode.
while (temp -> next ->next!=NULL)
temp =temp ->next;
Deletion at the end:
Moving to
last node
Deleting the last
node.
temp ->next =NULL;
Doubly linked list:
 In DLL each node contains both the address of
previous and next nodes.
Representation of Doubly Linked List:
Struct node{
struct node *prev;
int item;
struct node *next;
};
Operations on DLL:
 Creation.
 Insertion.
 Deletion.
 Traversing.
 Searching.
Circular linked List:
 A CLL doesn’t have starting and ending.
 We have 2 types of Circular linked list.
1. Circular Single Linked List.
2. Circular Double Linked List.
Circular Single LL:
A single linked list can be made a circular single
linked list by simply giving the address of the last
node as first node.
Thank You

More Related Content

PPTX
Unit II Data Structure 2hr topic - List - Operations.pptx
PPTX
DSA(1).pptx
PPTX
linkedlist.pptx
DOCX
coding in C- Create a function called reverseList that takes the head.docx
PPTX
Linked list
PPTX
Presentation174145555555556666666661.pptx
PPTX
Unit 5 linked list
PPTX
linkedlist-130914084342-phpapp02.pptx
Unit II Data Structure 2hr topic - List - Operations.pptx
DSA(1).pptx
linkedlist.pptx
coding in C- Create a function called reverseList that takes the head.docx
Linked list
Presentation174145555555556666666661.pptx
Unit 5 linked list
linkedlist-130914084342-phpapp02.pptx

Similar to Data Structures Linked List, Double Linked List (20)

PPT
17 linkedlist (1)
PDF
Singly linked list
PPTX
Doubly & Circular Linked Lists
PPT
Linkedlist
PPT
Unit7 C
PPTX
Insertion operation
PPTX
LEC_4,5_linked_list.pptx for single and double linked list
PPTX
LEC_4,5_linked_list.pptx this is Good for data structure
DOCX
DS UNIT5_BINARY TREES.docx
DOCX
Lab Week 2 Game Programming.docx
PPTX
C Exam Help
PPTX
Implemention of Linked list concept in Data Structures
PPT
Linked list1.ppt
PPTX
UNIT 3a.pptx
PPTX
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
PDF
Unit - 2.pdf
PPTX
linked list.pptxdj bdjbhjddnbfjdndvdhbfvgh
PPT
Fundamentals of data structures
PPTX
UNIT -4 Singly Linked List-kiruthika.pptx
PPTX
DSModule2.pptx
17 linkedlist (1)
Singly linked list
Doubly & Circular Linked Lists
Linkedlist
Unit7 C
Insertion operation
LEC_4,5_linked_list.pptx for single and double linked list
LEC_4,5_linked_list.pptx this is Good for data structure
DS UNIT5_BINARY TREES.docx
Lab Week 2 Game Programming.docx
C Exam Help
Implemention of Linked list concept in Data Structures
Linked list1.ppt
UNIT 3a.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Unit - 2.pdf
linked list.pptxdj bdjbhjddnbfjdndvdhbfvgh
Fundamentals of data structures
UNIT -4 Singly Linked List-kiruthika.pptx
DSModule2.pptx
Ad

Recently uploaded (20)

PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
PPT on Performance Review to get promotions
PPTX
Geodesy 1.pptx...............................................
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Welding lecture in detail for understanding
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Project quality management in manufacturing
PPTX
Sustainable Sites - Green Building Construction
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Construction Project Organization Group 2.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT on Performance Review to get promotions
Geodesy 1.pptx...............................................
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Welding lecture in detail for understanding
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Project quality management in manufacturing
Sustainable Sites - Green Building Construction
Internet of Things (IOT) - A guide to understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
bas. eng. economics group 4 presentation 1.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Construction Project Organization Group 2.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Ad

Data Structures Linked List, Double Linked List

  • 2. Linkedlist:  Linkedlist is a linear collections of nodes.  Node: A node contains 2 fields.  data item / information  Null/ Address of the next node.
  • 3. Linkedlist representation: Struct node{ int item; struct node *next; };
  • 4. Allocation of memory to a node:  Struct node *temp;  Temp=(struct node*) malloc (sizeof(struct node));  Temp is a node type pointer variable it can points to dynamic allocated memory.
  • 5. Accessing the temp:  Temp can be accessed by using the following code. temp->item= data temp->next= null / address of the next node
  • 6. Example of linkedlist Struct node *start; start=(struct node*) malloc (sizeof(struct node));
  • 7. Operations on linked list:  Creation.  Insertion.  Deletion.  Traversing.  Searching.
  • 8. Insertion:  At the beginning of the linkedlist.  In the middle of the linkedlist.  At the end of the linkedlist.
  • 9. Insertion at Beginning: To do so we have to follow the following code. Newnode= (struct node *)malloc(sizeof(struct node); Scanf(“%d”,&newnode->data); Newnode->next=NULL; Newnode creation
  • 10. Insertion at Beginning: Inserting at the begining Head->next= newnode; newnode =head; Newnode creation
  • 11. Insertion at middle: We have to go to the before position where we wanted to insert the n ode. for(i=1;i< pos -1;i++) temp =temp ->next; Newnode= (struct node *)malloc(sizeof(struct node); Scanf(“%d”,&newnode->data); Newnode->next=NULL; Newnode creation
  • 12. Insertion at middle: After we reached before position where we wanted to insert the node. Newnode ->next = Temp ->next; Temp ->next= newnode; Insert node in the specified position
  • 13. Insertion at end: We have to go to the end position where we wanted to insert the n ode. while (temp ->next!=NULL) temp=temp->next; Newnode= (struct node *)malloc(sizeof(struct node); Scanf(“%d”,&newnode->data); Newnode->next=NULL; Newnode creation
  • 14. Insertion at end: Temp ->next= newnode; Insert node in the specified position
  • 15. Deletion:  At the beginning of the linkedlist.  In the middle of the linkedlist.  At the end of the linkedlist.
  • 16. Deletion at Beginning: We have to delete the first node in the linked list. head = head ->next Deletion of First node
  • 17. Deletion at middle: Moving to specific node We have to go to the before position where we wanted to insert the n ode. for(i=1;i<pos-1;i++) temp = temp ->next;
  • 18. Deletion at middle: Deletion the node Deleting the specific node. newnode -> next= temp ->next; temp -> next = newnode;
  • 19. Deletion at the end: Moving to last nut one node We have to go to the before position where we wanted to insert the n ode. while (temp -> next ->next!=NULL) temp =temp ->next;
  • 20. Deletion at the end: Moving to last node Deleting the last node. temp ->next =NULL;
  • 21. Doubly linked list:  In DLL each node contains both the address of previous and next nodes.
  • 22. Representation of Doubly Linked List: Struct node{ struct node *prev; int item; struct node *next; };
  • 23. Operations on DLL:  Creation.  Insertion.  Deletion.  Traversing.  Searching.
  • 24. Circular linked List:  A CLL doesn’t have starting and ending.  We have 2 types of Circular linked list. 1. Circular Single Linked List. 2. Circular Double Linked List.
  • 25. Circular Single LL: A single linked list can be made a circular single linked list by simply giving the address of the last node as first node.