SlideShare a Scribd company logo
http://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm Copyright © tutorialspoint.com
DATA STRUCTURE - LINKED LISTDATA STRUCTURE - LINKED LIST
A linked-list is a sequence of data structures which are connected together via links.
Linked List is a sequence of links which contains items. Each link contains a connection to another
link. Linked list the second most used data structure after array. Following are important terms to
understand the concepts of Linked List.
Link − Each Link of a linked list can store a data called an element.
Next − Each Link of a linked list contain a link to next link called Next.
LinkedList − A LinkedList contains the connection link to the first Link called First.
Linked List Representation
Linked list can be visualized as a chain of nodes, where every node points to the next node.
As per above shown illustration, following are the important points to be considered.
LinkedList contains an link element called first.
Each Link carries a data fields and a Link Field called next.
Each Link is linked with its next link using its next link.
Last Link carries a Link as null to mark the end of the list.
Types of Linked List
Following are the various flavours of linked list.
Simple Linked List − Item Navigation is forward only.
Doubly Linked List − Items can be navigated forward and backward way.
Circular Linked List − Last item contains link of the first element as next and and first
element has link to last element as prev.
Basic Operations
Following are the basic operations supported by a list.
Insertion − add an element at the beginning of the list.
Deletion − delete an element at the beginning of the list.
Display − displaying complete list.
Search − search an element using given key.
Delete − delete an element using given key.
Insertion Operation
Adding a new node in linked list is a more than one step activity. We Shall learn this with diagrams
here. First, create a node using the same structure and find the location where it has to be
inserted.
Imagine that we are inserting a node B NewNode, between A LeftNode and C RightNode. Then point
B.next to C
NewNode.next −> RightNode;
It should look like this −
Now the next of the node at left should point to the new node.
LeftNode.next −> NewNode;
This will put the new node in the middle of the two. The new list should look like this −
Similar steps should be taken if the node being inserted at the beginning of the list. While putting it
at the end, then the second last node of list should point to new node and the new node will point
to NULL.
Deletion Operation
Deletion is also a more than one step process. We shall learn with pictorial representation. First,
locate the target node to be removed, by using searching algorithms.
The left previous node of the target node now should point to the next node of the target node −
LeftNode.next −> TargetNode.next;
This will remove the link that was pointing to target node. Now we shall remove to what target
node is pointing.
TargetNode.next −> NULL;
We need to use the deleted node we can keep that in memory otherwise we can simply deallocate
memory and wipe off the target node completely.
Reverse Operation
This operation is a thorough one. We need to make the last node be pointed by the head node and
reverse the whole linked list.
First, we traverse to the end of the list. It should be pointing to NULL. Now we shall make it to point
to its previous node −
We have to make sure that last node is not the lost node, so we'll have some temp node, which
looks like the head node pointing to the last node. Now we shall make our all our left side nodes to
point to their previous nodes one by one.
Except the node firstnode pointed by the head node, should point to their predecessor and making
them their new successor. The first node will point to NULL.
We'll make the head node to point the new first node by using temp node.
The linked-list is now reversed. To see linked-list implementation in C programming language,
please click here.
Loading [MathJax]/jax/output/HTML-CSS/jax.js

More Related Content

PPTX
data structure
PPT
Doubly linked list
PPTX
Doubly Linked List
PPTX
Linked list
DOC
Linked List
ODP
Linked List
PPT
Circular linked list
DOCX
Singlelinked list
data structure
Doubly linked list
Doubly Linked List
Linked list
Linked List
Linked List
Circular linked list
Singlelinked list

What's hot (19)

PDF
Doubly Link List
PDF
Circular linked list
PPT
Data Structure Lecture 5
PDF
Singly linked list
PPTX
Linked list
PPTX
Doubly linked list (animated)
PPTX
Insertion into linked lists
DOCX
Introduction to linked lists
PPTX
Linked lists 1
PPTX
Doubly circular linked list
PPTX
Linked stacks and queues
PPTX
Data Structures - Lecture 7 [Linked List]
PPT
Linked list
PPT
Data Structure Lecture 6
PPTX
Link list presentation slide(Daffodil international university)
PDF
Finalpresentationfordatastructure 161207052319
PPTX
Circular link list.ppt
PPT
Link List
PPTX
Link list
Doubly Link List
Circular linked list
Data Structure Lecture 5
Singly linked list
Linked list
Doubly linked list (animated)
Insertion into linked lists
Introduction to linked lists
Linked lists 1
Doubly circular linked list
Linked stacks and queues
Data Structures - Lecture 7 [Linked List]
Linked list
Data Structure Lecture 6
Link list presentation slide(Daffodil international university)
Finalpresentationfordatastructure 161207052319
Circular link list.ppt
Link List
Link list
Ad

Viewers also liked (9)

PDF
Dr. Chao top contributor - Risk Transfer is often used in place of Risk Sharing
PPTX
Macbeth psychological profiling- mood disorders
PPTX
Aplicaciones
PDF
Wolverhampton Children, Young People and Families Plan
PPTX
Lectores rss y servicios relacionados
DOCX
PPTX
PPT
¿Por qué MANGOSTAN?
PPSX
Dr. Chao top contributor - Risk Transfer is often used in place of Risk Sharing
Macbeth psychological profiling- mood disorders
Aplicaciones
Wolverhampton Children, Young People and Families Plan
Lectores rss y servicios relacionados
¿Por qué MANGOSTAN?
Ad

Similar to Linked list (20)

PPTX
Linked list, Singly link list and its operations
PPT
linked_lists.ppt linked_lists linked_lists
PPTX
PPTX
Linked List Representation of a Linked List.pptx
PPT
Data Structures- Part7 linked lists
PPT
Lecture 3 List of Data Structures & Algorithms
PPTX
Lec3-Linked list.pptx
PPTX
Data Structures_Linked List
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
Linked list.docx
PDF
Chapter 3 Linkedlist Data Structure .pdf
PPTX
Singly Linked List_Operations-Traversal.pptx
PPTX
Data Structures(Part 1)
PPT
Algo>ADT list & linked list
PPTX
LinkedList-VJ-V2.pptx Analysis of Algorithms and Data Structures
PPT
PPTX
linked list in data structure
PPTX
linked list using c
PPTX
Linked list (1).pptx
Linked list, Singly link list and its operations
linked_lists.ppt linked_lists linked_lists
Linked List Representation of a Linked List.pptx
Data Structures- Part7 linked lists
Lecture 3 List of Data Structures & Algorithms
Lec3-Linked list.pptx
Data Structures_Linked List
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 list.docx
Chapter 3 Linkedlist Data Structure .pdf
Singly Linked List_Operations-Traversal.pptx
Data Structures(Part 1)
Algo>ADT list & linked list
LinkedList-VJ-V2.pptx Analysis of Algorithms and Data Structures
linked list in data structure
linked list using c
Linked list (1).pptx

More from maamir farooq (20)

DOCX
Ooad lab1
PPT
Lesson 03
PPT
Lesson 02
PDF
Php client libray
PDF
Swiftmailer
PDF
PDF
PPTX
PDF
PDF
J query 1.7 cheat sheet
PDF
Assignment
PDF
Java script summary
PDF
PDF
PPTX
PPTX
Css summary
DOCX
Manual of image processing lab
PDF
Session management
PDF
Data management
PPTX
Content provider
Ooad lab1
Lesson 03
Lesson 02
Php client libray
Swiftmailer
J query 1.7 cheat sheet
Assignment
Java script summary
Css summary
Manual of image processing lab
Session management
Data management
Content provider

Recently uploaded (20)

PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Updated Idioms and Phrasal Verbs in English subject
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
Updated Idioms and Phrasal Verbs in English subject
Final Presentation General Medicine 03-08-2024.pptx
LDMMIA Reiki Yoga Finals Review Spring Summer
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
Microbial disease of the cardiovascular and lymphatic systems
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
UNIT III MENTAL HEALTH NURSING ASSESSMENT
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Yogi Goddess Pres Conference Studio Updates
Anesthesia in Laparoscopic Surgery in India
A systematic review of self-coping strategies used by university students to ...
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
What if we spent less time fighting change, and more time building what’s rig...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Chinmaya Tiranga quiz Grand Finale.pdf

Linked list

  • 1. http://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm Copyright © tutorialspoint.com DATA STRUCTURE - LINKED LISTDATA STRUCTURE - LINKED LIST A linked-list is a sequence of data structures which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list the second most used data structure after array. Following are important terms to understand the concepts of Linked List. Link − Each Link of a linked list can store a data called an element. Next − Each Link of a linked list contain a link to next link called Next. LinkedList − A LinkedList contains the connection link to the first Link called First. Linked List Representation Linked list can be visualized as a chain of nodes, where every node points to the next node. As per above shown illustration, following are the important points to be considered. LinkedList contains an link element called first. Each Link carries a data fields and a Link Field called next. Each Link is linked with its next link using its next link. Last Link carries a Link as null to mark the end of the list. Types of Linked List Following are the various flavours of linked list. Simple Linked List − Item Navigation is forward only. Doubly Linked List − Items can be navigated forward and backward way. Circular Linked List − Last item contains link of the first element as next and and first element has link to last element as prev. Basic Operations Following are the basic operations supported by a list. Insertion − add an element at the beginning of the list. Deletion − delete an element at the beginning of the list. Display − displaying complete list. Search − search an element using given key. Delete − delete an element using given key. Insertion Operation Adding a new node in linked list is a more than one step activity. We Shall learn this with diagrams here. First, create a node using the same structure and find the location where it has to be
  • 2. inserted. Imagine that we are inserting a node B NewNode, between A LeftNode and C RightNode. Then point B.next to C NewNode.next −> RightNode; It should look like this − Now the next of the node at left should point to the new node. LeftNode.next −> NewNode; This will put the new node in the middle of the two. The new list should look like this − Similar steps should be taken if the node being inserted at the beginning of the list. While putting it at the end, then the second last node of list should point to new node and the new node will point to NULL. Deletion Operation Deletion is also a more than one step process. We shall learn with pictorial representation. First, locate the target node to be removed, by using searching algorithms.
  • 3. The left previous node of the target node now should point to the next node of the target node − LeftNode.next −> TargetNode.next; This will remove the link that was pointing to target node. Now we shall remove to what target node is pointing. TargetNode.next −> NULL; We need to use the deleted node we can keep that in memory otherwise we can simply deallocate memory and wipe off the target node completely. Reverse Operation This operation is a thorough one. We need to make the last node be pointed by the head node and reverse the whole linked list. First, we traverse to the end of the list. It should be pointing to NULL. Now we shall make it to point to its previous node −
  • 4. We have to make sure that last node is not the lost node, so we'll have some temp node, which looks like the head node pointing to the last node. Now we shall make our all our left side nodes to point to their previous nodes one by one. Except the node firstnode pointed by the head node, should point to their predecessor and making them their new successor. The first node will point to NULL. We'll make the head node to point the new first node by using temp node. The linked-list is now reversed. To see linked-list implementation in C programming language, please click here. Loading [MathJax]/jax/output/HTML-CSS/jax.js