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
PDF
ds-lecture-4-171012041008 (1).pdf
PPTX
Linked list (1).pptx
PPTX
linked list in data structure
PPTX
DS_LinkedList.pptx
PPT
Lecture 3 List of Data Structures & Algorithms
PPT
PPT
PPT
PPTX
Linked list and its operations - Traversal
PDF
Linked Lists.pdf
PDF
4. Linked list .pdf
PPTX
Linked List Representation of a Linked List.pptx
PPTX
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
PPT
PPTX
RPT_03_A_Linked List presentation for FE
PPTX
Lec3-Linked list.pptx
DOCX
Linked list.docx
PPT
linked_lists.ppt linked_lists linked_lists
PPTX
Linked list
Linked list, Singly link list and its operations
ds-lecture-4-171012041008 (1).pdf
Linked list (1).pptx
linked list in data structure
DS_LinkedList.pptx
Lecture 3 List of Data Structures & Algorithms
Linked list and its operations - Traversal
Linked Lists.pdf
4. Linked list .pdf
Linked List Representation of a Linked List.pptx
UNIT 2LINKEDLISdddddddddddddddddddddddddddT.pptx
RPT_03_A_Linked List presentation for FE
Lec3-Linked list.pptx
Linked list.docx
linked_lists.ppt linked_lists linked_lists
Linked list

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)

PDF
Microbial disease of the cardiovascular and lymphatic systems
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Trump Administration's workforce development strategy
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
Microbial disease of the cardiovascular and lymphatic systems
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Trump Administration's workforce development strategy
Abdominal Access Techniques with Prof. Dr. R K Mishra
STATICS OF THE RIGID BODIES Hibbelers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
VCE English Exam - Section C Student Revision Booklet
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Microbial diseases, their pathogenesis and prophylaxis
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Yogi Goddess Pres Conference Studio Updates
Weekly quiz Compilation Jan -July 25.pdf
Final Presentation General Medicine 03-08-2024.pptx

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