SlideShare a Scribd company logo
2
Most read
3
Most read
7
Most read
Introduction to the Linked
Lists
By Kristina Barooah
Computer Science Engineering, Lovely Professional University
Technical Member of GeeksforGeeks-LPU.
What are Linked Lists?
A linked list is a linear data structure, in which the elements are not stored
at contiguous memory locations, rather stored in memory location which are
free! This is what make the date in a linked list scattered. The elements in a
linked list are linked using pointers as shown in the below image:
In simple words, a linked list consists of nodes where each node contains a
data field and a reference(link) to the next node in the list.
Anatomy of a Linked List
.
A linked list consists of a sequence of nodes.
• Each node contains a value and a link (pointer or reference) to some other
node.
• The last node contains a NULL link.
• The list may (or may not) have a header. Here myList is the header, it ONLY
stores the address of the first node.
• A node’s successor is the NEXT node in the sequence.
• The last node has no successor.
• A node’s predecessor is the PREVIOUS node in the sequence.
• The first node has no predecessor.
• A list’s length is the number of elements in it.
• A list containing no elements exits I.e., a linked list may be empty.
• LinkedList is a dynamic structure.
Important Points about Linked Lists
Array versus Linked Lists
Linked lists are more complex to code and manage than arrays, but they have
some distinct advantages of using linked lists over arrays.
1. Dynamic: A linked list is dynamic in nature which means it can easily grow and shrink
in size. We don’t need to know how many nodes will be in the list. They are created in
memory as needed. In contrast, the size of a C++ array is fixed at compilation time.
2. Easy and fast insertions and deletions: To insert or delete an element in an array,
we need to copy to temporary variables to make room for new elements or close the gap
caused by deleted elements. However, with a linked list, no need to move other nodes.
Only need to reset some pointers.
4. Another point of difference between
an array and a linked list is that a linked
list does not allow random access of
data.
3. Both arrays and linked lists are a
linear collection of data elements. But
unlike an array, a linked list does not
store its nodes in consecutive memory
locations.
How to create a simple Linked
List?
In C/C++, we can implement a linked list using the following code:
struct node
{
int data;
struct node *next;
};
• Linked lists provide an efficient way of storing related data and
perform basic operations such as insertion, deletion, and updation
of information at the cost of extra space required for storing
address of the next node.
Memory
Management
in Linked
Lists
Linked list in Data Structure and Algorithm
Types of Linked Lists
1. Singly linked lists
2. Doubly linked lists
3. Circular linked lists
Singly-linked lists
Doubly-linked lists
Creating a Doubly Linked List
In C/ C++, the structure of a doubly linked list can be given as, struct node
{ struct node *prev;
int data;
struct node *next; };
The PREV field of the first node and the NEXT field of the last node will contain
NULL
Memory representation of a Doubly Linked List
Circular linked lists
In a circular linked list, the last node contains a pointer to the first node of the list. We can
have a circular singly linked list as well as a circular doubly linked list. While traversing a
circular. Linked list, we can begin at any node and traverse the list in any direction, forward or
backward, until we reach the same node where we started. Thus, a circular linked list has no
beginning and no ending. It is abbreviated as CLL.
Memory representation of a Circular Linked list
Operations in Linked Lists
1. Traversing
2. Searching
3. Insertion
4. Deletion
Traversing a Singly Linked List
Step 1: [INITIALIZE] SET PTR = START
Step 2: Repeat Steps 3 and 4 while PTR !=
NULL
Step 3: Apply Process to PTR DATA
Step 4: SET PTR = PTR ->NEXT
[END OF LOOP]
Step 5: EXIT
Searching a Single Linked List
Step 1: [INITIALIZE] SET PTR = START
Step 2: Repeat Step 3,
while PTR != NULL
Step 3: IF VAL = PTR -> DATA
SET POS = PTR
Go To Step 5
ELSE
SET PTR = PTR -> NEXT
[END OF IF]
[END OF LOOP]
Step 4: SET POS = NULL
Step 5: EXIT
If we have VAL = 4, then the flow of the algorithm can be explained as shown in the
figure:
Insertion in
linked list
Case 1: The new node is
inserted at the beginning.
Case 2: The new node is
inserted at the end.
Case 3: The new node is
inserted after a given node.
Case 4: The new node is
inserted before a given node.
Deletion in
linked list
Case 1: Deleting the First
Node from a Linked List.
Case 2: Deleting the Last
Node from a Linked List.
Case 3: Deleting the Node
After a Given Node in a
Linked List.
APPLICATIONS OF LINKED LIST
• Linked Lists can be used to implement Stacks , Queues.
• Linked Lists can also be used to implement Graphs. (Adjacency list representation of Graph).
• Implementing Hash Tables :- Each Bucket of the hash table can itself be a linked list. (Open chain
hashing).
• Undo functionality in Photoshop or Word . Linked list of states.
• A polynomial can be represented in an array or in a linked list by simply storing the coefficient and
exponent of each term.
• However, for any polynomial operation , such as addition or multiplication of polynomials , linked list
representation is easier to deal with.
• Linked lists are useful for dynamic memory allocation.
• The real-life application where the circular linked list is used is our Personal Computers, where
multiple applications are running.
• All the running applications are kept in a circular linked list and the OS gives a fixed time slot to all for

More Related Content

PPTX
Poisson distribution
Anindya Jana
 
PPS
Cache memory
Anuj Modi
 
PPTX
Assistive Technology Presentation
Salazec Spratling
 
PPTX
What is Application Software?
DaisyJeffenYRios
 
PPT
OOP in C++
ppd1961
 
PPTX
Social media powerpoint presentation
Slideegg
 
PPTX
Getting started with entity framework
Lushanthan Sivaneasharajah
 
Poisson distribution
Anindya Jana
 
Cache memory
Anuj Modi
 
Assistive Technology Presentation
Salazec Spratling
 
What is Application Software?
DaisyJeffenYRios
 
OOP in C++
ppd1961
 
Social media powerpoint presentation
Slideegg
 
Getting started with entity framework
Lushanthan Sivaneasharajah
 

What's hot (20)

PPTX
Linked list
KalaivaniKS1
 
PPTX
Binary Search Tree in Data Structure
Dharita Chokshi
 
PDF
Linked list implementation of Queue
Dr. Sindhia Lingaswamy
 
PPTX
Queue - Data Structure - Notes
Omprakash Chauhan
 
PPTX
Abstract Data Types
karthikeyanC40
 
PDF
sparse matrix in data structure
MAHALAKSHMI P
 
PPTX
stack & queue
manju rani
 
PPTX
Insertion in singly linked list
Keval Bhogayata
 
PPTX
linked list in Data Structure, Simple and Easy Tutorial
Afzal Badshah
 
PPTX
linked list in data structure
shameen khan
 
PPSX
Data Structure (Queue)
Adam Mukharil Bachtiar
 
PPT
Linked lists
SARITHA REDDY
 
PPTX
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
 
PPTX
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
PPTX
Introduction to data structure
NUPOORAWSARMOL
 
PPSX
Stack
Seema Sharma
 
PPTX
Linked List
Ashim Lamichhane
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Linked list
KalaivaniKS1
 
Binary Search Tree in Data Structure
Dharita Chokshi
 
Linked list implementation of Queue
Dr. Sindhia Lingaswamy
 
Queue - Data Structure - Notes
Omprakash Chauhan
 
Abstract Data Types
karthikeyanC40
 
sparse matrix in data structure
MAHALAKSHMI P
 
stack & queue
manju rani
 
Insertion in singly linked list
Keval Bhogayata
 
linked list in Data Structure, Simple and Easy Tutorial
Afzal Badshah
 
linked list in data structure
shameen khan
 
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Linked lists
SARITHA REDDY
 
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
 
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
Complexity of Algorithm
Muhammad Muzammal
 
Introduction to data structure
NUPOORAWSARMOL
 
Linked List
Ashim Lamichhane
 
Data Structures (CS8391)
Elavarasi K
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Ad

Similar to Linked list in Data Structure and Algorithm (20)

PPTX
link list.pptx complete notes detailed ans
IqraHanif27
 
PPTX
Linked List Representation of a Linked List.pptx
AAUsH2
 
PDF
Linked list (introduction) 1
DrSudeshna
 
PPTX
1.3 Linked List.pptx
ssuserd2f031
 
PPTX
Data Structures and Algorithms - Lec 05.pptx
RameshaFernando2
 
PDF
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 
PPTX
Linked list (1).pptx
rajveersingh643731
 
PPT
Linkedlists
Rajendran
 
PPTX
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
PPT
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
PPTX
Data Structures-UNIT Four_Linked_List.pptx
shilpar780389
 
PPTX
linked list in dsa python (presentation)
MirzaAbdullahTariq
 
PPT
ANOITO2341988888888888888888888885555.ppt
robertobula2
 
PPT
Link list using array in Data structure amd algorithms
pwstudent403
 
DOCX
Introduction to linked lists
pooja kumari
 
PPTX
data structures and applications power p
MeghaKulkarni27
 
DOCX
Linked List
BHARATH KUMAR
 
PPTX
RPT_03_A_Linked List presentation for FE
AshishFamt
 
PPT
linked_lists.ppt linked_lists linked_lists
AmsaAzeem
 
DOCX
Link list assi
PATILPANKAJ106130
 
link list.pptx complete notes detailed ans
IqraHanif27
 
Linked List Representation of a Linked List.pptx
AAUsH2
 
Linked list (introduction) 1
DrSudeshna
 
1.3 Linked List.pptx
ssuserd2f031
 
Data Structures and Algorithms - Lec 05.pptx
RameshaFernando2
 
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 
Linked list (1).pptx
rajveersingh643731
 
Linkedlists
Rajendran
 
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
Data Structures-UNIT Four_Linked_List.pptx
shilpar780389
 
linked list in dsa python (presentation)
MirzaAbdullahTariq
 
ANOITO2341988888888888888888888885555.ppt
robertobula2
 
Link list using array in Data structure amd algorithms
pwstudent403
 
Introduction to linked lists
pooja kumari
 
data structures and applications power p
MeghaKulkarni27
 
Linked List
BHARATH KUMAR
 
RPT_03_A_Linked List presentation for FE
AshishFamt
 
linked_lists.ppt linked_lists linked_lists
AmsaAzeem
 
Link list assi
PATILPANKAJ106130
 
Ad

Recently uploaded (20)

PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
demidovs1
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PDF
5 Influence line.pdf for structural engineers
Endalkazene
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PPTX
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
Software Testing Tools - names and explanation
shruti533256
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
demidovs1
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
5 Influence line.pdf for structural engineers
Endalkazene
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 

Linked list in Data Structure and Algorithm

  • 1. Introduction to the Linked Lists By Kristina Barooah Computer Science Engineering, Lovely Professional University Technical Member of GeeksforGeeks-LPU.
  • 2. What are Linked Lists? A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations, rather stored in memory location which are free! This is what make the date in a linked list scattered. The elements in a linked list are linked using pointers as shown in the below image: In simple words, a linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list.
  • 3. Anatomy of a Linked List . A linked list consists of a sequence of nodes. • Each node contains a value and a link (pointer or reference) to some other node. • The last node contains a NULL link. • The list may (or may not) have a header. Here myList is the header, it ONLY stores the address of the first node.
  • 4. • A node’s successor is the NEXT node in the sequence. • The last node has no successor. • A node’s predecessor is the PREVIOUS node in the sequence. • The first node has no predecessor. • A list’s length is the number of elements in it. • A list containing no elements exits I.e., a linked list may be empty. • LinkedList is a dynamic structure. Important Points about Linked Lists
  • 5. Array versus Linked Lists Linked lists are more complex to code and manage than arrays, but they have some distinct advantages of using linked lists over arrays. 1. Dynamic: A linked list is dynamic in nature which means it can easily grow and shrink in size. We don’t need to know how many nodes will be in the list. They are created in memory as needed. In contrast, the size of a C++ array is fixed at compilation time. 2. Easy and fast insertions and deletions: To insert or delete an element in an array, we need to copy to temporary variables to make room for new elements or close the gap caused by deleted elements. However, with a linked list, no need to move other nodes. Only need to reset some pointers.
  • 6. 4. Another point of difference between an array and a linked list is that a linked list does not allow random access of data. 3. Both arrays and linked lists are a linear collection of data elements. But unlike an array, a linked list does not store its nodes in consecutive memory locations.
  • 7. How to create a simple Linked List? In C/C++, we can implement a linked list using the following code: struct node { int data; struct node *next; }; • Linked lists provide an efficient way of storing related data and perform basic operations such as insertion, deletion, and updation of information at the cost of extra space required for storing address of the next node.
  • 10. Types of Linked Lists 1. Singly linked lists 2. Doubly linked lists 3. Circular linked lists
  • 13. Creating a Doubly Linked List In C/ C++, the structure of a doubly linked list can be given as, struct node { struct node *prev; int data; struct node *next; }; The PREV field of the first node and the NEXT field of the last node will contain NULL
  • 14. Memory representation of a Doubly Linked List
  • 15. Circular linked lists In a circular linked list, the last node contains a pointer to the first node of the list. We can have a circular singly linked list as well as a circular doubly linked list. While traversing a circular. Linked list, we can begin at any node and traverse the list in any direction, forward or backward, until we reach the same node where we started. Thus, a circular linked list has no beginning and no ending. It is abbreviated as CLL.
  • 16. Memory representation of a Circular Linked list
  • 17. Operations in Linked Lists 1. Traversing 2. Searching 3. Insertion 4. Deletion
  • 18. Traversing a Singly Linked List Step 1: [INITIALIZE] SET PTR = START Step 2: Repeat Steps 3 and 4 while PTR != NULL Step 3: Apply Process to PTR DATA Step 4: SET PTR = PTR ->NEXT [END OF LOOP] Step 5: EXIT
  • 19. Searching a Single Linked List Step 1: [INITIALIZE] SET PTR = START Step 2: Repeat Step 3, while PTR != NULL Step 3: IF VAL = PTR -> DATA SET POS = PTR Go To Step 5 ELSE SET PTR = PTR -> NEXT [END OF IF] [END OF LOOP] Step 4: SET POS = NULL Step 5: EXIT If we have VAL = 4, then the flow of the algorithm can be explained as shown in the figure:
  • 20. Insertion in linked list Case 1: The new node is inserted at the beginning. Case 2: The new node is inserted at the end. Case 3: The new node is inserted after a given node. Case 4: The new node is inserted before a given node.
  • 21. Deletion in linked list Case 1: Deleting the First Node from a Linked List. Case 2: Deleting the Last Node from a Linked List. Case 3: Deleting the Node After a Given Node in a Linked List.
  • 22. APPLICATIONS OF LINKED LIST • Linked Lists can be used to implement Stacks , Queues. • Linked Lists can also be used to implement Graphs. (Adjacency list representation of Graph). • Implementing Hash Tables :- Each Bucket of the hash table can itself be a linked list. (Open chain hashing). • Undo functionality in Photoshop or Word . Linked list of states. • A polynomial can be represented in an array or in a linked list by simply storing the coefficient and exponent of each term. • However, for any polynomial operation , such as addition or multiplication of polynomials , linked list representation is easier to deal with. • Linked lists are useful for dynamic memory allocation. • The real-life application where the circular linked list is used is our Personal Computers, where multiple applications are running. • All the running applications are kept in a circular linked list and the OS gives a fixed time slot to all for