SlideShare a Scribd company logo
Linked List
VARIOUS TYPES OF LINKED LIST
able of Contents
 Circular Linked List
 Linked Implementation of Stack
 Linked Implementation of Queue
Application of Linked List
Concept of Linked List
 Linked list is a linear data structure.
 A Linked List is a set of nodes where each node has two fields ‘data’
and ‘link’.
DATA LINK
 Piece of Information
Data Type : Int,char,float etc.
Used to point to next node
C Representation of Simple Linked List
 C structure for creating a node in a Linked List :
typedef struct node
{
int data;
struct node *next;
}NODE;
Stores Information part of data
Stores address of next node
Circular Linked List
 Circular linked list is a sequence of elements in which every element
has link to its next element in the sequence and the last element has
the link to the first element in the sequence.
 The circular linked list is as shown below :
10 20 30 40 50
Head Node
Operation performed on Circular Linked List
 The following operation can be performed on Circular linked list.
1. Insertion
2. Deletion
3. Display
Insertion of Circular Linked list
 Algorithm:
Step 1: Create a new_node with a given value.
Step 2: Check whether list is empty (head==NULL).
Step 3: If empty, then head=new_node and new_node→next=head.
Step 4: If not empty then create a temp node pointer and initialize with
‘head’.
Step 5: Move temp node to its next node, until head node not achieved
(temp→next==head).
Step 6: Set new_node→next=head, head=new_node and
temp→next=head.
Inserting a node as a head node
 Algorithm:
Step 1: Create a new_node with a given value.
Step 2: Check whether list is empty (head==NULL).
Step 3: If empty, then head=new_node and new_node→next=head.
Step 4: If not empty then create a temp node pointer and initialize with
‘head’.
Step 5: Move temp node to its next node, until head node not achieved
(temp->next==head).
Step 6: Set temp→next=new_node and new_node→next=head.
Inserting a node as a last node
 Algorithm:
Step 1: Create a new_node with a given value.
Step 2: Check whether list is empty (head==NULL).
Step 3: If empty, then head=new_node and new_node->next=head.
Step 4: If not empty then create a temp node pointer and initialize with
‘head’.
Step 5: Define key value after which the node is to be inserted.
Step 6: Check for key value (temp→data==key).
Step 7: Every time check whether temp is reached to the last node or
not. If yes then print Node not found.
Step 8: If temp=key then check whether it is last node
(temp→next==head).
Step 9: If temp is last node then temp->next=new_node and
new_node→next=head.
Step 10: If temp is not last node then new_node→next=temp→next and
temp→next=new_node.
Inserting a node at specific location
Deletion of any node
 Algorithm:
Step 1: Check whether list is Empty (head == NULL).
Step 2: If it is Empty then, print list is empty.
Step 3: If it is Not Empty then, define two Node pointers 'temp1' and
'temp2' and initialize 'temp1' with head.
Step 4: Keep moving the temp1 until it reaches to the specified or to the
last node. And every time set 'temp2 = temp1' before moving the
'temp1' to its next node.
Step 5: If it is reached to the last node then display Node not found.
Step 6: If it is reached to the exact node which we want to delete, then
check whether list is having only one node (temp1→next == head).
Step 7: If list has only one node and that is the node to be deleted then
set head=NULL and delete temp1 (free(temp1)).
Step 8: If list contains multiple nodes then check whether temp1 is the
first node in the list (temp1 == head).
Step 9: If temp1 is the first node then set temp2 = head and keep
moving temp2 to its next node until temp2 reaches to the last node.
Then set head=head→next, temp2→next=head and delete temp1.
Step 10: If temp1 is not first node then check whether it is last node in
the list (temp1→next == head).
Step 11: If temp1 is last node then set temp2→next=head and delete
temp1 (free(temp1)).
Step 12: If temp1 is not first node and not last node then set
temp2→next = temp1→next and delete temp1 (free(temp1)).
Display Circular Linked List
 Algorithm:
Step 1: Check whether list is Empty (head == NULL).
Step 2: If it is Empty, then print list is empty.
Step 3: If it is Not Empty then, define a Node pointer 'temp' and
initialize with head.
Step 4: Keep displaying temp→data with an arrow (--->) until temp
reaches to the last node.
Step 5: Finally display temp→data with arrow pointing to head→data.
Advantages of Circular Linked list over Singly Linked
list
 In Circular linked list, the next pointer of last node in pointing to the
head node.
 Hence we can move from last node to the head node of the list very
efficiently.
 So, accessing of any node is much faster then singly linked list.
 The last node’s next pointer have null value in singly linked list while
in circular linked list it is having the address of the head node.
 Hence there is no loss of memory.
Linked Implementation of Stack
 Stack is a special case of list and therefore we can represent stack
using arrays as well as using linked list.
 The advantage of implementing stack using linked list is that we
need not have to worry about the size of the stack.
 Since we are using linked list as stack, we are inserting the nodes in
the stack and the size is dynamically changed. So there is not stack
full (Overflow condition).
C structure of Linked
Stack
Representation of Linked
Stack
struct stack
{
int data;
struct stack *next;
}NODE;
40
30
20
10 NULL
Top Node
Insert a node into Linked Stack
 We can insert the node using user defined function named
push(value).
 Algorithm:
 Step 1: Create a new_node with given value.
 Step 2: Check whether stack is Empty (top == NULL).
 Step 3: If it is Empty, then set new_node→next=NULL.
 Step 4: If it is Not Empty, then set new_node→next=top.
 Step 5: set top = new_node.
Delete a node from Linked Stack
 We can delete a node from linked stack using user defined function
called pop().
 Algorithm:
 Step 1: Check whether stack is Empty (top == NULL).
 Step 2: If it is Empty, then display “Stack is empty”.
 Step 3: If it is Not Empty, then define a Node pointer 'temp' and set it
to 'top'.
 Step 4: Then set 'top = top → next'.
 Step 5: Delete 'temp' (free(temp)).
Display Linked Stack
 Algorithm:
 Step 1: Check whether stack is Empty (top == NULL).
 Step 2: If it is Empty, then display “Stack is Empty”.
 Step 3: If it is Not Empty, then define a Node pointer 'temp' and
initialize with top.
 Step 4: Display 'temp → data --->' and move it to the next node.
Repeat the same until temp reaches to the first node in the stack
(temp → next != NULL).
 Step 5: Display 'temp → data ---> NULL'.
Linked Implementation of Queue
 We can implement queue using linked list.
 The main advantage is we need not have to worry about size of the
queue, so there will not be a queue full condition.
 The left most pointer is called front node and the right most pointer is
called rear node.
 We can not remove any arbitrary node from queue.
C structure of Linked
Queue
Representation of Linked
Queue
struct node
{
int data;
struct stack *next;
}Q;
40302010
Front
node
Rear
node
Insert a node into Linked Queue
 Algorithm:
 Step 1: Create a new_node and set new_node → next = NULL.
 Step 2: Check whether queue is Empty (rear == NULL)
 Step 3: If it is Empty then, set front = new_node and rear =
new_node.
 Step 4: If it is Not Empty then, set rear→next = new_node and rear =
new_node.
Delete a node from Linked Queue
 Algorithm:
 Step 1: Check whether queue is Empty (front == NULL).
 Step 2: If it is Empty, then display "Queue is Empty!!!”
 Step 3: If it is Not Empty then, define a Node pointer temp and set it
to front.
 Step 4: Then 'front = front → next' and delete 'temp' (free(temp)).
Display Linked Queue
 Algorithm:
 Step 1: Check whether queue is Empty (front == NULL).
 Step 2: If it is Empty then, display “Queue is Empty!!!”
 Step 3: If it is Not Empty then, define a Node pointer temp and
initialize with front.
 Step 4: Display temp → data ---> and move it to the next node.
Repeat the same until temp reaches to 'rear' (temp → next != NULL).
 Step 5: Display temp → data ---> NULL.
Application of Linked List
 Various application of linked list are :
1. Representation of polynomial and performing various operations
such as addition, multiplication and evaluation on it.
2. Performing addition of long positive integers.
3. Representing non integer and non homogeneous list.
Linked list

More Related Content

PPT
Singly link list
PPTX
linked list in Data Structure, Simple and Easy Tutorial
PPT
Linked List
PPTX
Linked List
PPTX
Data Structures - Lecture 7 [Linked List]
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
PDF
Binary Search - Design & Analysis of Algorithms
PPTX
Heap sort
Singly link list
linked list in Data Structure, Simple and Easy Tutorial
Linked List
Linked List
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Binary Search - Design & Analysis of Algorithms
Heap sort

What's hot (20)

PPT
Operations on linked list
PPTX
PDF
Singly linked list
PPTX
Doubly linked list (animated)
PPT
Doubly linked list
PPTX
Recursion in Data Structure
PPTX
Binary Tree in Data Structure
PPT
Merge sort
PPTX
Doubly linked list
PPTX
single linked list
PPTX
Ppt on Linked list,stack,queue
PPTX
Doubly Linked List
PPT
Data Structures- Part7 linked lists
PPTX
Linear data structure concepts
PPT
Lec 17 heap data structure
PPTX
Data Structures - Lecture 8 [Sorting Algorithms]
PPTX
Linked List - Insertion & Deletion
PPT
BINARY TREE REPRESENTATION.ppt
PPTX
Arrays in Data Structure and Algorithm
PDF
Linked list implementation of Stack
Operations on linked list
Singly linked list
Doubly linked list (animated)
Doubly linked list
Recursion in Data Structure
Binary Tree in Data Structure
Merge sort
Doubly linked list
single linked list
Ppt on Linked list,stack,queue
Doubly Linked List
Data Structures- Part7 linked lists
Linear data structure concepts
Lec 17 heap data structure
Data Structures - Lecture 8 [Sorting Algorithms]
Linked List - Insertion & Deletion
BINARY TREE REPRESENTATION.ppt
Arrays in Data Structure and Algorithm
Linked list implementation of Stack
Ad

Similar to Linked list (20)

PPTX
Linked list data structures and algorithms
PPTX
queue
PPTX
Circular linked list
PPTX
Data structure and algorithm list structures
DOCX
lab stack and queue.docx
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
PPTX
Linked lists in Data Structure
PPTX
LinkedList-VJ-V2.pptx Analysis of Algorithms and Data Structures
PPTX
DSA chapter 4.pptxhdjaaaaaadjhsssssssssssssssssssssssssss
PPTX
Revisiting a data structures in detail with linked list stack and queue
PPTX
Linked list
PPTX
linkedlist-130914084342-phpapp02.pptx
PPTX
linked list.pptxdj bdjbhjddnbfjdndvdhbfvgh
PPTX
Unit 5 linked list
PPT
Mi 103 linked list
PPTX
Dounly linked list
PPTX
VCE Unit 02 (1).pptx
PPTX
stacks and queues
PPTX
CIRCULAR LINKED LIST _
Linked list data structures and algorithms
queue
Circular linked list
Data structure and algorithm list structures
lab stack and queue.docx
LEC_4,5_linked_list.pptx for single and double linked list
LEC_4,5_linked_list.pptx this is Good for data structure
Linked lists in Data Structure
LinkedList-VJ-V2.pptx Analysis of Algorithms and Data Structures
DSA chapter 4.pptxhdjaaaaaadjhsssssssssssssssssssssssssss
Revisiting a data structures in detail with linked list stack and queue
Linked list
linkedlist-130914084342-phpapp02.pptx
linked list.pptxdj bdjbhjddnbfjdndvdhbfvgh
Unit 5 linked list
Mi 103 linked list
Dounly linked list
VCE Unit 02 (1).pptx
stacks and queues
CIRCULAR LINKED LIST _
Ad

Recently uploaded (20)

PPTX
Welding lecture in detail for understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
composite construction of structures.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
web development for engineering and engineering
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPT
Mechanical Engineering MATERIALS Selection
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Digital Logic Computer Design lecture notes
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Geodesy 1.pptx...............................................
PPTX
Internet of Things (IOT) - A guide to understanding
Welding lecture in detail for understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
composite construction of structures.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Foundation to blockchain - A guide to Blockchain Tech
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
web development for engineering and engineering
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mechanical Engineering MATERIALS Selection
OOP with Java - Java Introduction (Basics)
Digital Logic Computer Design lecture notes
Embodied AI: Ushering in the Next Era of Intelligent Systems
Geodesy 1.pptx...............................................
Internet of Things (IOT) - A guide to understanding

Linked list

  • 2. VARIOUS TYPES OF LINKED LIST able of Contents  Circular Linked List  Linked Implementation of Stack  Linked Implementation of Queue Application of Linked List
  • 3. Concept of Linked List  Linked list is a linear data structure.  A Linked List is a set of nodes where each node has two fields ‘data’ and ‘link’. DATA LINK  Piece of Information Data Type : Int,char,float etc. Used to point to next node
  • 4. C Representation of Simple Linked List  C structure for creating a node in a Linked List : typedef struct node { int data; struct node *next; }NODE; Stores Information part of data Stores address of next node
  • 5. Circular Linked List  Circular linked list is a sequence of elements in which every element has link to its next element in the sequence and the last element has the link to the first element in the sequence.  The circular linked list is as shown below : 10 20 30 40 50 Head Node
  • 6. Operation performed on Circular Linked List  The following operation can be performed on Circular linked list. 1. Insertion 2. Deletion 3. Display
  • 7. Insertion of Circular Linked list  Algorithm: Step 1: Create a new_node with a given value. Step 2: Check whether list is empty (head==NULL). Step 3: If empty, then head=new_node and new_node→next=head. Step 4: If not empty then create a temp node pointer and initialize with ‘head’. Step 5: Move temp node to its next node, until head node not achieved (temp→next==head). Step 6: Set new_node→next=head, head=new_node and temp→next=head. Inserting a node as a head node
  • 8.  Algorithm: Step 1: Create a new_node with a given value. Step 2: Check whether list is empty (head==NULL). Step 3: If empty, then head=new_node and new_node→next=head. Step 4: If not empty then create a temp node pointer and initialize with ‘head’. Step 5: Move temp node to its next node, until head node not achieved (temp->next==head). Step 6: Set temp→next=new_node and new_node→next=head. Inserting a node as a last node
  • 9.  Algorithm: Step 1: Create a new_node with a given value. Step 2: Check whether list is empty (head==NULL). Step 3: If empty, then head=new_node and new_node->next=head. Step 4: If not empty then create a temp node pointer and initialize with ‘head’. Step 5: Define key value after which the node is to be inserted. Step 6: Check for key value (temp→data==key). Step 7: Every time check whether temp is reached to the last node or not. If yes then print Node not found. Step 8: If temp=key then check whether it is last node (temp→next==head). Step 9: If temp is last node then temp->next=new_node and new_node→next=head. Step 10: If temp is not last node then new_node→next=temp→next and temp→next=new_node. Inserting a node at specific location
  • 10. Deletion of any node  Algorithm: Step 1: Check whether list is Empty (head == NULL). Step 2: If it is Empty then, print list is empty. Step 3: If it is Not Empty then, define two Node pointers 'temp1' and 'temp2' and initialize 'temp1' with head. Step 4: Keep moving the temp1 until it reaches to the specified or to the last node. And every time set 'temp2 = temp1' before moving the 'temp1' to its next node. Step 5: If it is reached to the last node then display Node not found. Step 6: If it is reached to the exact node which we want to delete, then check whether list is having only one node (temp1→next == head).
  • 11. Step 7: If list has only one node and that is the node to be deleted then set head=NULL and delete temp1 (free(temp1)). Step 8: If list contains multiple nodes then check whether temp1 is the first node in the list (temp1 == head). Step 9: If temp1 is the first node then set temp2 = head and keep moving temp2 to its next node until temp2 reaches to the last node. Then set head=head→next, temp2→next=head and delete temp1. Step 10: If temp1 is not first node then check whether it is last node in the list (temp1→next == head). Step 11: If temp1 is last node then set temp2→next=head and delete temp1 (free(temp1)). Step 12: If temp1 is not first node and not last node then set temp2→next = temp1→next and delete temp1 (free(temp1)).
  • 12. Display Circular Linked List  Algorithm: Step 1: Check whether list is Empty (head == NULL). Step 2: If it is Empty, then print list is empty. Step 3: If it is Not Empty then, define a Node pointer 'temp' and initialize with head. Step 4: Keep displaying temp→data with an arrow (--->) until temp reaches to the last node. Step 5: Finally display temp→data with arrow pointing to head→data.
  • 13. Advantages of Circular Linked list over Singly Linked list  In Circular linked list, the next pointer of last node in pointing to the head node.  Hence we can move from last node to the head node of the list very efficiently.  So, accessing of any node is much faster then singly linked list.  The last node’s next pointer have null value in singly linked list while in circular linked list it is having the address of the head node.  Hence there is no loss of memory.
  • 14. Linked Implementation of Stack  Stack is a special case of list and therefore we can represent stack using arrays as well as using linked list.  The advantage of implementing stack using linked list is that we need not have to worry about the size of the stack.  Since we are using linked list as stack, we are inserting the nodes in the stack and the size is dynamically changed. So there is not stack full (Overflow condition).
  • 15. C structure of Linked Stack Representation of Linked Stack struct stack { int data; struct stack *next; }NODE; 40 30 20 10 NULL Top Node
  • 16. Insert a node into Linked Stack  We can insert the node using user defined function named push(value).  Algorithm:  Step 1: Create a new_node with given value.  Step 2: Check whether stack is Empty (top == NULL).  Step 3: If it is Empty, then set new_node→next=NULL.  Step 4: If it is Not Empty, then set new_node→next=top.  Step 5: set top = new_node.
  • 17. Delete a node from Linked Stack  We can delete a node from linked stack using user defined function called pop().  Algorithm:  Step 1: Check whether stack is Empty (top == NULL).  Step 2: If it is Empty, then display “Stack is empty”.  Step 3: If it is Not Empty, then define a Node pointer 'temp' and set it to 'top'.  Step 4: Then set 'top = top → next'.  Step 5: Delete 'temp' (free(temp)).
  • 18. Display Linked Stack  Algorithm:  Step 1: Check whether stack is Empty (top == NULL).  Step 2: If it is Empty, then display “Stack is Empty”.  Step 3: If it is Not Empty, then define a Node pointer 'temp' and initialize with top.  Step 4: Display 'temp → data --->' and move it to the next node. Repeat the same until temp reaches to the first node in the stack (temp → next != NULL).  Step 5: Display 'temp → data ---> NULL'.
  • 19. Linked Implementation of Queue  We can implement queue using linked list.  The main advantage is we need not have to worry about size of the queue, so there will not be a queue full condition.  The left most pointer is called front node and the right most pointer is called rear node.  We can not remove any arbitrary node from queue.
  • 20. C structure of Linked Queue Representation of Linked Queue struct node { int data; struct stack *next; }Q; 40302010 Front node Rear node
  • 21. Insert a node into Linked Queue  Algorithm:  Step 1: Create a new_node and set new_node → next = NULL.  Step 2: Check whether queue is Empty (rear == NULL)  Step 3: If it is Empty then, set front = new_node and rear = new_node.  Step 4: If it is Not Empty then, set rear→next = new_node and rear = new_node.
  • 22. Delete a node from Linked Queue  Algorithm:  Step 1: Check whether queue is Empty (front == NULL).  Step 2: If it is Empty, then display "Queue is Empty!!!”  Step 3: If it is Not Empty then, define a Node pointer temp and set it to front.  Step 4: Then 'front = front → next' and delete 'temp' (free(temp)).
  • 23. Display Linked Queue  Algorithm:  Step 1: Check whether queue is Empty (front == NULL).  Step 2: If it is Empty then, display “Queue is Empty!!!”  Step 3: If it is Not Empty then, define a Node pointer temp and initialize with front.  Step 4: Display temp → data ---> and move it to the next node. Repeat the same until temp reaches to 'rear' (temp → next != NULL).  Step 5: Display temp → data ---> NULL.
  • 24. Application of Linked List  Various application of linked list are : 1. Representation of polynomial and performing various operations such as addition, multiplication and evaluation on it. 2. Performing addition of long positive integers. 3. Representing non integer and non homogeneous list.