SlideShare a Scribd company logo
Prepared By:
Dr. Chandan Kumar
Assistant Professor, Computer Science & Engineering Department
Invertis University, Bareilly
INTRODUCTION
 A linked list is a linear data structure which is used to
store a collection of elements.
 Each element in a linked list is represented by node.
 It is a best example of dynamic data structure that uses
pointer for the implementation
 Each node contain two parts
 Data part or info part - which is used to store the element
 Link part or address part- which is used to stores the link to
the next node.
Node
Data Link
INTRODUCTION
• Linked list require more memory compare to array for
the same size of the elements because along with data
or value it also store pointer to next node.
• It is the most common and simplest data structure. They
can be used to implement other data structure like
stack and queue etc.
• Finally, we can say that a linked list is a set of
dynamically allocated nodes, organized in
such a way that each node has a value and a pointer.
INTRODUCTION
• Arrays and Linked Lists are both linear data structures so
they do have some advantages and drawbacks over
each other.
• Now let us look at the difference between arrays and
linked list.
ARRAYS VS LINKED LIST
Arrays
• Collection of elements of
similar data type
• Support random access
using indexing
• Best suitable for fixed size
elements implementation
• Insertion and deletion of
elements are inefficient i.e.
elements are usually shifted
Linked Lists
 An ordered collection of
elements of the same type
where each element is
linked using pointers to the
next one.
 Doesn’t support random
access
 Support Dynamic size
 Insertion and deletion of
elements are efficient i.e.
no shifting
ARRAYS VS LINKED LIST
Arrays
 Memory is allocated
statically or compile time
 Wastage of memory if the
allocated memory is not
fully utilized
 Data elements are stored in
computer memory in
contiguous location; so
access is faster
 Size must be specified at
the time of array
declaration
Linked Lists
• Memory is allocated
dynamically or run time
• There is no wastage of
memory
• New elements can be stored
anywhere, and use pointers
to create a reference for the
new element; so access is
slow
• Size of a Linked list
grows/shrinks as and when
new elements are
inserted/deleted.
TYPES OF LINKED LIST
• There are two types of linked list
• Single or Singly linked list (SLL)
• Single Circular Linked List
• Double or Doubly linked list (DLL)
• Double Circular Linked List
SINGLY LINKED LIST (SLL)
 This is a fundamental type of linked list
 Each node has two part
 Data or info part- contain actual value or information
 Next or link part – contain pointer or address of the next
node
 Last node contain NULL value in link part which
indicated end of the node
 Traversing is allowed only in forward direction
 It uses less memory as compare to doubly linked list per
node ( Single pointer)
SINGLY LINKED LIST (SLL)
• Complexity of insertion and deletion at a known
position is O(n)
• We prefer SLL If we need to save memory and
searching is not required
• Singly linked list can mostly be used for stacks
SINGLY LINKED LIST (SLL)
• For Example
The above figure shows a singly linked list. The first
node is always used as a reference to traverse the
list and is called HEAD. The last node points
to NULL.
ANOITO2341988888888888888888888885555.ppt
SINGLY LINKED LIST (SLL)
• A Singly linked list can be implemented in C
programming langauge using the structure and
the pointer.
struct LinkedList
{
int data;
struct LinkedList *next;
};
This definition is used to build
every node in the list.
The data field stores the element
, and the next field is a pointer
to store the next node's address.
IMPLEMENTATION OF SLL IN C
LANGUAGE
#include<conio.h>
#include<stdio.h>
void main()
{
struct node
{
int value;
struct node *next;
}*a,*b,*c;
clrscr();
a->value=5;
b->value=6;
c->value=7;
IMPLEMENTATION OF SLL IN C
LANGUAGE
a->next=b;
b->next=c;
c->next=NULL;
printf("nNode an value=%d and Next =%u",a->value,a-
>next);
printf("nNode bn value=%d and next =%u",a->next-
>value,a->next->next);
printf("nNode cn value=%d and next=%u",a->next->next-
>value,a->next->next->next);
getch();
}
OUTPUT
SINGLE CIRCULAR LINKED
LIST
 Each node has two parts like SLL
 No beginning and No end
 Does not contain NULL pointer like SLL
 Last node is connected to first node i.e. link part of last
node contain address of first node
 Traversing allowed only in forward direction
 Time saving when we want to go from last node to first
node
 A good example where it is used is a timesharing
problem solved by operating system
SINGLE CIRCULAR LINKED
LIST
• For example
DOUBLY LINKED LIST (DLL)
• Each node has three parts, one data part and two link
part
• Data part contain actual value
• One link part contain next pointer to point next node
• Another link part contain previous pointer to point
previous node
DOUBLY LINKED LIST (DLL)
// C language to represent a node for DLL
struct node
{
int info;
struct node *next;
struct node *prev;
};
DOUBLY LINKED LIST (DLL)
 Traversing is possible in both directions i.e. forward and
backward directions
 Required more memory as compare to SLL for the
same size ( two pointers required)
 Previous link part value of first node and next link part
value of last node has value NULL
 Complexity of insertion and deletion at a known
position is O(1)
 We prefer DLL If we need better performance while
searching and memory is not a limitation
 Can be used to implement stacks, heaps, binary trees
DOUBLY LINKED LIST (DLL)
For Example:
DOUBLY CIRCULAR
LINKED LIST
 Each node has three parts like DLL
 No beginning and No end
 Does not contain NULL pointer like DLL
 First node is connected to the last node and Last node
is connected to first node i.e. previous pointer of the
first node contain address of last node and next pointer
of last node contain address of first node
 Traversing allowed in both directions i.e. forward and
backward directions
 Time saving when we want to go from last node to first
node and vice versa
DOUBLY CIRCULAR
LINKED LIST
• For example
OPERATION PERFORMED
ON LINKED LIST
The operations which can be performed on a linked list
follow:
1.Creation
2.Insertion
3.Deletion
4.Traversing
5.Searching
6.Concatenation
7.Display
CREATION
• This operation is used to create a linked list
• Memory allocated for nodes
Creating first node
head = (node*) malloc (sizeof(node));
head -> data = 50;
head -> next = NULL;
INSERTION
• Used to insert a new node in the linked list
• Insertion take place at different places such as
• At beginning of the linked list
• At the end of the linked list
• At specified position i.e. between any two nodes
• Inserting a node is a more than one step activity
• Created node must be in same structure
INSERTION
• At beginning of the linked list
• Here we want to add Node X
Before inserting Node X
INSERTION
After inserting Node X
New Node becomes new head of the linked list and next
pointer points to the Node A
INSERTION
 At the end of the linked list
 Here we want to add Node X
Before inserting Node X
INSERTION
After inserting Node X
next pointer of Node D pointes to new Node X and
the value of next pointer of Node D becomes NULL
INSERTION
 At specified position i.e. between any two nodes
 Here we want to add Node X between Node B and
Node C
Before inserting Node X
INSERTION
After inserting Node X
Here, next pointer of Node B pointes to new Node X and next
pointer of Node X pointes to Node C
DELETION
• Used to delete a node from the list
• Deletion take place at different places such as similarly
insertion operation
• From beginning of the linked list
• From the end of the linked list
• From specified position i.e. between any two nodes
• Deleting a node is a more than one step activity
DELETION
• Here we want to delete third node i.e. Node C from the
linked list
• Next pointer of node B points to Node D
• Similarly other deletion process will be done
TRAVERSING
• It is a process of examine all nodes of linked list i.e. one
end to the other end
• Recursive function is used to traverse a linked list in a
reverse order
• Going through first node to last node is called forward
traversing
• Going through last node to first node is called
backward traversing
SEARCHING
• Process to find a desired element in the linked list
• Sequential or linear search is the most common search
used in linked list
• Traverse all nodes one by one and matches with key
value
• There are two outcomes
• Search is successful, if desired element is found in the
linked list
• Search is unsuccessful, is desired element is not found in
the linked list
CONCATENATION
• Process of appending second list to the end of the first
list
• After concatenation, the linked list size will increases
• This is simply done by pointing next pointer of last node
of first linked list to first node of the second linked list
DISPLAY
• Used to print information of each nodes in a linked list
• Also display complete linked list
ANOITO2341988888888888888888888885555.ppt

More Related Content

PPT
Linked List
PPT
Link list using array in Data structure amd algorithms
PPTX
Linked Lists, Single Linked list and its operations
PPTX
Datastucture-Unit 4-Linked List Presentation.pptx
PDF
ds-lecture-4-171012041008 (1).pdf
PPTX
DLL DATA STRUCT.pptx
PPTX
linked list in data structure
PPTX
Linked list (1).pptx
Linked List
Link list using array in Data structure amd algorithms
Linked Lists, Single Linked list and its operations
Datastucture-Unit 4-Linked List Presentation.pptx
ds-lecture-4-171012041008 (1).pdf
DLL DATA STRUCT.pptx
linked list in data structure
Linked list (1).pptx

Similar to ANOITO2341988888888888888888888885555.ppt (20)

PPTX
Linked list in Data Structure and Algorithm
PPTX
link list.pptx complete notes detailed ans
PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPTX
Linked list
PPT
Data Structures- Part7 linked lists
PPTX
1.3 Linked List.pptx
PPTX
Data Structures Introduction & Linear DS
PDF
Linked list (introduction) 1
PPTX
Linked List.pptx
PPTX
module 3-.pptx
PPTX
Linear data structure concepts
PPTX
Data Structures_Linear data structures Linked Lists.pptx
PDF
Link list
PPTX
RPT_03_A_Linked List presentation for FE
PPT
Linkedlists
PPTX
Linked lists linked lists vs Arrays.pptx
PDF
Data Structure Lecture 3 Linked Lists.pdf
PPTX
data structures and applications power p
PPTX
Linked List
Linked list in Data Structure and Algorithm
link list.pptx complete notes detailed ans
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
Linked list
Data Structures- Part7 linked lists
1.3 Linked List.pptx
Data Structures Introduction & Linear DS
Linked list (introduction) 1
Linked List.pptx
module 3-.pptx
Linear data structure concepts
Data Structures_Linear data structures Linked Lists.pptx
Link list
RPT_03_A_Linked List presentation for FE
Linkedlists
Linked lists linked lists vs Arrays.pptx
Data Structure Lecture 3 Linked Lists.pdf
data structures and applications power p
Linked List
Ad

More from robertobula2 (16)

PPTX
DBMS-APPS-grade-10 apps for REVIEWER.pptx
PPTX
GIMME 5 game for activity or for ice breaker.pptx
PPTX
Information Managment Activity21321213.pptx
PPTX
Enterprise Architecture200123215452.pptx
PPTX
Activity443422345656544333556465434.pptx
PPTX
Structured-Query-Language1112234123.pptx
PPTX
DBMS-APPS-grade-1012312311232112312.pptx
PPTX
gen-information-of-computer-quiz121.pptx
PPTX
Quiz-Beetheinternet12544552248752364.pptx
PPTX
QUIZ for sample providing learners .pptx
PPTX
GIMME 5 activity game for studentss.pptx
PPTX
ELIMINATION ROUND for ISAAL game plan.pptx
PPTX
ictasaplatformforchange-copy-180320052715.pptx
PPTX
698655848-Designing-and-Developing-an-ICT-Project-for-Social.pptx
PDF
TCP_ TECHNOLOGY FOR TEACHING AND LEARNING_SYNCH 5 DIGITAL LITERACY SKILLS.pdf
PPTX
698655848-Designing-and-Developing-an-ICT-Project-for-Social.pptx
DBMS-APPS-grade-10 apps for REVIEWER.pptx
GIMME 5 game for activity or for ice breaker.pptx
Information Managment Activity21321213.pptx
Enterprise Architecture200123215452.pptx
Activity443422345656544333556465434.pptx
Structured-Query-Language1112234123.pptx
DBMS-APPS-grade-1012312311232112312.pptx
gen-information-of-computer-quiz121.pptx
Quiz-Beetheinternet12544552248752364.pptx
QUIZ for sample providing learners .pptx
GIMME 5 activity game for studentss.pptx
ELIMINATION ROUND for ISAAL game plan.pptx
ictasaplatformforchange-copy-180320052715.pptx
698655848-Designing-and-Developing-an-ICT-Project-for-Social.pptx
TCP_ TECHNOLOGY FOR TEACHING AND LEARNING_SYNCH 5 DIGITAL LITERACY SKILLS.pdf
698655848-Designing-and-Developing-an-ICT-Project-for-Social.pptx
Ad

Recently uploaded (20)

PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
PPTX
lec_5(probability).pptxzzjsjsjsjsjsjjsjjssj
PPTX
Extract Transformation Load (3) (1).pptx
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
Logistic Regression ml machine learning.pptx
PDF
Digital Infrastructure – Powering the Connected Age
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PPTX
Global journeys: estimating international migration
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PDF
.pdf is not working space design for the following data for the following dat...
PDF
Chad Readey - An Independent Thinker
PPTX
Challenges and opportunities in feeding a growing population
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Trading Procedures (1).pptxcffcdddxxddsss
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Reliability_Chapter_ presentation 1221.5784
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
lec_5(probability).pptxzzjsjsjsjsjsjjsjjssj
Extract Transformation Load (3) (1).pptx
Major-Components-ofNKJNNKNKNKNKronment.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Logistic Regression ml machine learning.pptx
Digital Infrastructure – Powering the Connected Age
Business Acumen Training GuidePresentation.pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
Global journeys: estimating international migration
Moving the Public Sector (Government) to a Digital Adoption
.pdf is not working space design for the following data for the following dat...
Chad Readey - An Independent Thinker
Challenges and opportunities in feeding a growing population
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Trading Procedures (1).pptxcffcdddxxddsss
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf

ANOITO2341988888888888888888888885555.ppt

  • 1. Prepared By: Dr. Chandan Kumar Assistant Professor, Computer Science & Engineering Department Invertis University, Bareilly
  • 2. INTRODUCTION  A linked list is a linear data structure which is used to store a collection of elements.  Each element in a linked list is represented by node.  It is a best example of dynamic data structure that uses pointer for the implementation  Each node contain two parts  Data part or info part - which is used to store the element  Link part or address part- which is used to stores the link to the next node. Node Data Link
  • 3. INTRODUCTION • Linked list require more memory compare to array for the same size of the elements because along with data or value it also store pointer to next node. • It is the most common and simplest data structure. They can be used to implement other data structure like stack and queue etc. • Finally, we can say that a linked list is a set of dynamically allocated nodes, organized in such a way that each node has a value and a pointer.
  • 4. INTRODUCTION • Arrays and Linked Lists are both linear data structures so they do have some advantages and drawbacks over each other. • Now let us look at the difference between arrays and linked list.
  • 5. ARRAYS VS LINKED LIST Arrays • Collection of elements of similar data type • Support random access using indexing • Best suitable for fixed size elements implementation • Insertion and deletion of elements are inefficient i.e. elements are usually shifted Linked Lists  An ordered collection of elements of the same type where each element is linked using pointers to the next one.  Doesn’t support random access  Support Dynamic size  Insertion and deletion of elements are efficient i.e. no shifting
  • 6. ARRAYS VS LINKED LIST Arrays  Memory is allocated statically or compile time  Wastage of memory if the allocated memory is not fully utilized  Data elements are stored in computer memory in contiguous location; so access is faster  Size must be specified at the time of array declaration Linked Lists • Memory is allocated dynamically or run time • There is no wastage of memory • New elements can be stored anywhere, and use pointers to create a reference for the new element; so access is slow • Size of a Linked list grows/shrinks as and when new elements are inserted/deleted.
  • 7. TYPES OF LINKED LIST • There are two types of linked list • Single or Singly linked list (SLL) • Single Circular Linked List • Double or Doubly linked list (DLL) • Double Circular Linked List
  • 8. SINGLY LINKED LIST (SLL)  This is a fundamental type of linked list  Each node has two part  Data or info part- contain actual value or information  Next or link part – contain pointer or address of the next node  Last node contain NULL value in link part which indicated end of the node  Traversing is allowed only in forward direction  It uses less memory as compare to doubly linked list per node ( Single pointer)
  • 9. SINGLY LINKED LIST (SLL) • Complexity of insertion and deletion at a known position is O(n) • We prefer SLL If we need to save memory and searching is not required • Singly linked list can mostly be used for stacks
  • 10. SINGLY LINKED LIST (SLL) • For Example The above figure shows a singly linked list. The first node is always used as a reference to traverse the list and is called HEAD. The last node points to NULL.
  • 12. SINGLY LINKED LIST (SLL) • A Singly linked list can be implemented in C programming langauge using the structure and the pointer. struct LinkedList { int data; struct LinkedList *next; }; This definition is used to build every node in the list. The data field stores the element , and the next field is a pointer to store the next node's address.
  • 13. IMPLEMENTATION OF SLL IN C LANGUAGE #include<conio.h> #include<stdio.h> void main() { struct node { int value; struct node *next; }*a,*b,*c; clrscr(); a->value=5; b->value=6; c->value=7;
  • 14. IMPLEMENTATION OF SLL IN C LANGUAGE a->next=b; b->next=c; c->next=NULL; printf("nNode an value=%d and Next =%u",a->value,a- >next); printf("nNode bn value=%d and next =%u",a->next- >value,a->next->next); printf("nNode cn value=%d and next=%u",a->next->next- >value,a->next->next->next); getch(); }
  • 16. SINGLE CIRCULAR LINKED LIST  Each node has two parts like SLL  No beginning and No end  Does not contain NULL pointer like SLL  Last node is connected to first node i.e. link part of last node contain address of first node  Traversing allowed only in forward direction  Time saving when we want to go from last node to first node  A good example where it is used is a timesharing problem solved by operating system
  • 18. DOUBLY LINKED LIST (DLL) • Each node has three parts, one data part and two link part • Data part contain actual value • One link part contain next pointer to point next node • Another link part contain previous pointer to point previous node
  • 19. DOUBLY LINKED LIST (DLL) // C language to represent a node for DLL struct node { int info; struct node *next; struct node *prev; };
  • 20. DOUBLY LINKED LIST (DLL)  Traversing is possible in both directions i.e. forward and backward directions  Required more memory as compare to SLL for the same size ( two pointers required)  Previous link part value of first node and next link part value of last node has value NULL  Complexity of insertion and deletion at a known position is O(1)  We prefer DLL If we need better performance while searching and memory is not a limitation  Can be used to implement stacks, heaps, binary trees
  • 21. DOUBLY LINKED LIST (DLL) For Example:
  • 22. DOUBLY CIRCULAR LINKED LIST  Each node has three parts like DLL  No beginning and No end  Does not contain NULL pointer like DLL  First node is connected to the last node and Last node is connected to first node i.e. previous pointer of the first node contain address of last node and next pointer of last node contain address of first node  Traversing allowed in both directions i.e. forward and backward directions  Time saving when we want to go from last node to first node and vice versa
  • 24. OPERATION PERFORMED ON LINKED LIST The operations which can be performed on a linked list follow: 1.Creation 2.Insertion 3.Deletion 4.Traversing 5.Searching 6.Concatenation 7.Display
  • 25. CREATION • This operation is used to create a linked list • Memory allocated for nodes Creating first node head = (node*) malloc (sizeof(node)); head -> data = 50; head -> next = NULL;
  • 26. INSERTION • Used to insert a new node in the linked list • Insertion take place at different places such as • At beginning of the linked list • At the end of the linked list • At specified position i.e. between any two nodes • Inserting a node is a more than one step activity • Created node must be in same structure
  • 27. INSERTION • At beginning of the linked list • Here we want to add Node X Before inserting Node X
  • 28. INSERTION After inserting Node X New Node becomes new head of the linked list and next pointer points to the Node A
  • 29. INSERTION  At the end of the linked list  Here we want to add Node X Before inserting Node X
  • 30. INSERTION After inserting Node X next pointer of Node D pointes to new Node X and the value of next pointer of Node D becomes NULL
  • 31. INSERTION  At specified position i.e. between any two nodes  Here we want to add Node X between Node B and Node C Before inserting Node X
  • 32. INSERTION After inserting Node X Here, next pointer of Node B pointes to new Node X and next pointer of Node X pointes to Node C
  • 33. DELETION • Used to delete a node from the list • Deletion take place at different places such as similarly insertion operation • From beginning of the linked list • From the end of the linked list • From specified position i.e. between any two nodes • Deleting a node is a more than one step activity
  • 34. DELETION • Here we want to delete third node i.e. Node C from the linked list • Next pointer of node B points to Node D • Similarly other deletion process will be done
  • 35. TRAVERSING • It is a process of examine all nodes of linked list i.e. one end to the other end • Recursive function is used to traverse a linked list in a reverse order • Going through first node to last node is called forward traversing • Going through last node to first node is called backward traversing
  • 36. SEARCHING • Process to find a desired element in the linked list • Sequential or linear search is the most common search used in linked list • Traverse all nodes one by one and matches with key value • There are two outcomes • Search is successful, if desired element is found in the linked list • Search is unsuccessful, is desired element is not found in the linked list
  • 37. CONCATENATION • Process of appending second list to the end of the first list • After concatenation, the linked list size will increases • This is simply done by pointing next pointer of last node of first linked list to first node of the second linked list
  • 38. DISPLAY • Used to print information of each nodes in a linked list • Also display complete linked list