SlideShare a Scribd company logo
1
Linked List
Link − Each link of a linked list can store a data
called an element.
Next − Each link of a linked list contains a link to
the next link called Next.
Linked List − A Linked List contains the
connection link to the first link called head.
2
3
Types of Linked List
• Single Linked List − Item navigation is forward
only.
• Doubly Linked List − Items can be navigated
forward and backward.
• Circular Linked List − Last item contains link of
the first element as next and the first element
has a link to the last element as previous.
4
Operations of Linked List
• Insert − Add an element into list.
• Delete − Remove an element of the list.
• Search − Searches an element using the given
key.
• Sort - Sort List elements
• Merge – Join 2 list elements
• Display − Displays the complete list.
5
Insert Routine
6
Delete Routine
7
Double Linked List
• Data
• Forward link
• Backward link
8
Insert
9
Delete routine
10
Application of Linked List
• Polynomial ADT
• Radix Sort
• Multilist
11
Circular Linked List
Singly Linked List
• Pointer of the last node points to the first node
Doubly linked list
• The next pointer of the last node points to the first node and the previous
pointer of the first node points to the last node making the circular in both
directions.
12
Circular Linked List
Singly Linked List
struct node
{
int data;
struct node *next;
};
typedef struct node *list;
typedef struct node *position;
Doubly Linked List
struct node
{
int data;
struct node *flink;
struct node *blink;
};
struct node *head;
13
Insertion
1. Insertion at the beginning of the list
2. Insertion at the end of the list
3. Insertion in between the nodes
14
Insertion at the beginning of the list
struct Node *addBegin(struct Node *last, int data)
{
// Creating a node dynamically.
struct Node *temp = (struct Node *)malloc(sizeof(struct Node));
// Assigning the data.
temp -> data = data;
// Adjusting the links.
head=temp;
temp -> next = last -> next;
last -> next = temp;
return last;
}
15
Insertion at the end of the list
struct Node *addEnd(struct Node *last, int data)
{
// Creating a node dynamically.
struct Node *temp = (struct Node *)malloc( sizeof(struct Node));
// Assigning the data.
temp -> data = data;
// Adjusting the links.
temp -> next = last -> next;
last -> next = temp;
last = temp;
return last;
}
16
Deletion
• Deletion at beginning
• Deletion at last
• Deletion at middle
17
delete
node* deleteNode(int x)
{
//searching the Node with data x
node *n = search(x);
node *ptr = head;
if(ptr == NULL)
{
printf( "List is empty“);
return NULL;
}
else if(ptr == n)
{
head = n->next;
last->next=head;
return n;
}
else
{
while(ptr->next != n)
{
ptr = ptr->next;
}
ptr->next = n->next;
return n;
}
}

More Related Content

DOC
Linked List
DOCX
Linked list.docx
PPTX
Linked list
PDF
Circular linked list
PPTX
linkedlistforslideshare-210123143943.pptx
PPTX
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
PPTX
Lec3-Linked list.pptx
PDF
linkrd_list.pdf
Linked List
Linked list.docx
Linked list
Circular linked list
linkedlistforslideshare-210123143943.pptx
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
Lec3-Linked list.pptx
linkrd_list.pdf

Similar to data structures Linked List concept.pptx (20)

PPTX
Linked list and its operations - Traversal
PPTX
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
PPTX
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
PPTX
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
PPTX
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
PPTX
5.Linked list
PDF
Lec-4_Linked-List (1).pdf
PPTX
Linked list
PPTX
Deleting a node from the list(SINGLE LINKED LIST)
PPTX
Data Structures_Linked List
PPTX
DSL Unit 4 (Linked list) (PPT)SE3rd sem sppu.pptx
PPT
Linked list
PPT
Linked list
PPT
Linked list
PPT
Linked list
PPT
Linked list
PPT
Linked list
PPT
Linked list
PPTX
DS_LinkedList.pptx
PPTX
Unit 5 linked list
Linked list and its operations - Traversal
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
deletionfromsinglewaylinkedlistandsearch-180407173723.pptx
5.Linked list
Lec-4_Linked-List (1).pdf
Linked list
Deleting a node from the list(SINGLE LINKED LIST)
Data Structures_Linked List
DSL Unit 4 (Linked list) (PPT)SE3rd sem sppu.pptx
Linked list
Linked list
Linked list
Linked list
Linked list
Linked list
Linked list
DS_LinkedList.pptx
Unit 5 linked list
Ad

Recently uploaded (20)

PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Types and Its function , kingdom of life
PDF
Updated Idioms and Phrasal Verbs in English subject
PDF
Complications of Minimal Access Surgery at WLH
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Lesson notes of climatology university.
PPTX
master seminar digital applications in india
PDF
Trump Administration's workforce development strategy
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
A systematic review of self-coping strategies used by university students to ...
Cell Types and Its function , kingdom of life
Updated Idioms and Phrasal Verbs in English subject
Complications of Minimal Access Surgery at WLH
LDMMIA Reiki Yoga Finals Review Spring Summer
Paper A Mock Exam 9_ Attempt review.pdf.
Chinmaya Tiranga quiz Grand Finale.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
01-Introduction-to-Information-Management.pdf
What if we spent less time fighting change, and more time building what’s rig...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Computing-Curriculum for Schools in Ghana
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Weekly quiz Compilation Jan -July 25.pdf
Lesson notes of climatology university.
master seminar digital applications in india
Trump Administration's workforce development strategy
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Ad

data structures Linked List concept.pptx

  • 1. 1 Linked List Link − Each link of a linked list can store a data called an element. Next − Each link of a linked list contains a link to the next link called Next. Linked List − A Linked List contains the connection link to the first link called head.
  • 2. 2
  • 3. 3 Types of Linked List • Single Linked List − Item navigation is forward only. • Doubly Linked List − Items can be navigated forward and backward. • Circular Linked List − Last item contains link of the first element as next and the first element has a link to the last element as previous.
  • 4. 4 Operations of Linked List • Insert − Add an element into list. • Delete − Remove an element of the list. • Search − Searches an element using the given key. • Sort - Sort List elements • Merge – Join 2 list elements • Display − Displays the complete list.
  • 7. 7 Double Linked List • Data • Forward link • Backward link
  • 10. 10 Application of Linked List • Polynomial ADT • Radix Sort • Multilist
  • 11. 11 Circular Linked List Singly Linked List • Pointer of the last node points to the first node Doubly linked list • The next pointer of the last node points to the first node and the previous pointer of the first node points to the last node making the circular in both directions.
  • 12. 12 Circular Linked List Singly Linked List struct node { int data; struct node *next; }; typedef struct node *list; typedef struct node *position; Doubly Linked List struct node { int data; struct node *flink; struct node *blink; }; struct node *head;
  • 13. 13 Insertion 1. Insertion at the beginning of the list 2. Insertion at the end of the list 3. Insertion in between the nodes
  • 14. 14 Insertion at the beginning of the list struct Node *addBegin(struct Node *last, int data) { // Creating a node dynamically. struct Node *temp = (struct Node *)malloc(sizeof(struct Node)); // Assigning the data. temp -> data = data; // Adjusting the links. head=temp; temp -> next = last -> next; last -> next = temp; return last; }
  • 15. 15 Insertion at the end of the list struct Node *addEnd(struct Node *last, int data) { // Creating a node dynamically. struct Node *temp = (struct Node *)malloc( sizeof(struct Node)); // Assigning the data. temp -> data = data; // Adjusting the links. temp -> next = last -> next; last -> next = temp; last = temp; return last; }
  • 16. 16 Deletion • Deletion at beginning • Deletion at last • Deletion at middle
  • 17. 17 delete node* deleteNode(int x) { //searching the Node with data x node *n = search(x); node *ptr = head; if(ptr == NULL) { printf( "List is empty“); return NULL; } else if(ptr == n) { head = n->next; last->next=head; return n; } else { while(ptr->next != n) { ptr = ptr->next; } ptr->next = n->next; return n; } }