SlideShare a Scribd company logo
Insertion in Singly Linked List
Linked List
• What is a Linked List?
Linked List is a data structure.
It is collection of nodes.
Linked List is used widely because it do not need continue memory slot,
because the data stored in linked list is accessed through ‘Links’.
Singly Linked List
In a singly linked list node includes a ‘data’ part and a ‘link’ part.
Node :
Data: It includes any information that is to be stored.
Link: It have the address of the next consecutive node.
Data Link
Insertion
(1) Data Structures are used so that a data can be easily modified and
accessed.
(2) This modification includes: Insertion, Updating of Value, Delete and
some other special operations.
(3) Insertion is needed in a data structure for adding a value or
information while making it first time or it can also take place after it
has been made once completely. That is why insertion may happen in
any part of the data structure: At First, At Middle or At Last.
Insertion in Singly Linked List
• Insertion in Singly Linked list is quite convenient in compare to array
like structure.
• In a structure like array a number of shifts may take place which is not
at all acceptable.
• In a Singly Linked List only swap of two links are needed for single
insertion.
• We have discussed Insertion at first, at middle and at last in the singly
linked list.
Node creation
• For insertion first we have to create a new node and for creating a
new node we have to find whether required space is available or not.
• For doing so:
Say AVAIL=‘Pointer showing Available Space’
If(AVAIL==NULL)
Output: Space not available
Else : New node gets available space and AVAIL shifts to next
available free space if it exists.
‘Data’ and ‘Link’ part of New Node
• After space allocation to the New Node.
The ‘Data’ Part is given the desired value &
The ‘Link’ Part have initially NULL value.
After the insertion of node in the singly linked list the ‘Link’ part is
updated accordingly.
Insertion at First
For insertion at first the New Node should point to the first node
(before insertion) and start should point to the New Node.
For doing so:
New_Node -> Link = Start;
Start = New_node;
Insertion at Middle
For insertion at Middle the New Node should point to the node
next to it and the previous node should point to the New Node.
For doing so:
New_Node -> Link = Previous_node -> Link
Previous_node -> Link = New_node;
Insertion at Last
For Insertion at last the last node (before insertion) should point the
New Node and the ‘Link’ part of New Node must be NULL.
For doing so:
Last_Node -> Link = New_node;
Traversal
For Insertion at Middle and Insertion at Last we have to traverse till
previous and last node respectively.
To reach till desired Node we have to stop the traversal at some specific
point. To do this we have to ask user whether he wants insertion
before or after specific value OR before or after specific position.
Conditions
Condition to stop traversal at desired point
* Initialize Count with 1. # PTR =Pointer that is traversing.
Before given value (PTR -> Next) -> Data = ‘Value’ [#]
After given value PTR -> Data = ‘Value’ [#]
Before given position Count == ‘Position’ – 1 [*]
After given position Count == ‘Position’ [*]
Process Summary
(1) Create a New Node
(2) Apply values to the ‘Data’ and ‘Link’ part.
[Link part is NULL initially]
(3) Traverse in the linked list until we reach to the desired point.
(4) Insert Node using swaps of links.
Thank You.

More Related Content

What's hot

Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
Zidny Nafan
 
Linklist
LinklistLinklist
Doubly circular linked list
Doubly circular linked listDoubly circular linked list
Doubly circular linked list
Roshan Chaudhary
 
Merge sort algorithm power point presentation
Merge sort algorithm power point presentationMerge sort algorithm power point presentation
Merge sort algorithm power point presentation
University of Science and Technology Chitttagong
 
Quick sort
Quick sortQuick sort
Quick sort
Afaq Mansoor Khan
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
chauhankapil
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
almaqboli
 
Singly link list
Singly link listSingly link list
Singly link list
Rojin Khadka
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Sorting
SortingSorting
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
Jsaddam Hussain
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Circular Queue data structure
Circular Queue data structureCircular Queue data structure
Circular Queue data structure
Dhananjaysinh Jhala
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
Apurbo Datta
 
Quick sort
Quick sortQuick sort
Quick sort
amar kakde
 

What's hot (20)

Queue ppt
Queue pptQueue ppt
Queue ppt
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Linklist
LinklistLinklist
Linklist
 
Doubly circular linked list
Doubly circular linked listDoubly circular linked list
Doubly circular linked list
 
Merge sort algorithm power point presentation
Merge sort algorithm power point presentationMerge sort algorithm power point presentation
Merge sort algorithm power point presentation
 
Quick sort
Quick sortQuick sort
Quick sort
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Singly link list
Singly link listSingly link list
Singly link list
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Sorting
SortingSorting
Sorting
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Circular Queue data structure
Circular Queue data structureCircular Queue data structure
Circular Queue data structure
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Quick sort
Quick sortQuick sort
Quick sort
 

Similar to Insertion in singly linked list

Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5
Kumar
 
5.Linked list
5.Linked list 5.Linked list
5.Linked list
Mandeep Singh
 
Linked list.docx
Linked list.docxLinked list.docx
Linked list.docx
EmilyMengich
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 
Linkedlist
LinkedlistLinkedlist
Singly linked list
Singly linked listSingly linked list
Singly linked list
Amar Jukuntla
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
rajveersingh643731
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
ThenmozhiK5
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptx
msohail37
 
DSModule2.pptx
DSModule2.pptxDSModule2.pptx
DSModule2.pptx
ChrisSosaJacob
 
Lec3-Linked list.pptx
Lec3-Linked list.pptxLec3-Linked list.pptx
Lec3-Linked list.pptx
FaheemMahmood2
 
Linked Lists in Python, Python Institute in Delhi.pdf
Linked Lists in Python, Python Institute in Delhi.pdfLinked Lists in Python, Python Institute in Delhi.pdf
Linked Lists in Python, Python Institute in Delhi.pdf
ESS Institute
 
Linked List
Linked ListLinked List
Linked List
CHANDAN KUMAR
 
Linked list
Linked listLinked list
Linked list
Wasif Khan
 
Linked Lists.pdf
Linked Lists.pdfLinked Lists.pdf
Linked Lists.pdf
Kaynattariq1
 
DS Module 03.pdf
DS Module 03.pdfDS Module 03.pdf
DS Module 03.pdf
SonaPathak5
 
Linked list
Linked listLinked list
data structures lists operation of lists
data structures lists operation of listsdata structures lists operation of lists
data structures lists operation of lists
muskans14
 

Similar to Insertion in singly linked list (20)

Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5
 
5.Linked list
5.Linked list 5.Linked list
5.Linked list
 
Linked list.docx
Linked list.docxLinked list.docx
Linked list.docx
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptx
 
DSModule2.pptx
DSModule2.pptxDSModule2.pptx
DSModule2.pptx
 
Lec3-Linked list.pptx
Lec3-Linked list.pptxLec3-Linked list.pptx
Lec3-Linked list.pptx
 
Linked Lists in Python, Python Institute in Delhi.pdf
Linked Lists in Python, Python Institute in Delhi.pdfLinked Lists in Python, Python Institute in Delhi.pdf
Linked Lists in Python, Python Institute in Delhi.pdf
 
Linked List
Linked ListLinked List
Linked List
 
Linked list
Linked listLinked list
Linked list
 
Linked Lists.pdf
Linked Lists.pdfLinked Lists.pdf
Linked Lists.pdf
 
DS Module 03.pdf
DS Module 03.pdfDS Module 03.pdf
DS Module 03.pdf
 
Linked list
Linked listLinked list
Linked list
 
data structures lists operation of lists
data structures lists operation of listsdata structures lists operation of lists
data structures lists operation of lists
 

More from Keval Bhogayata

Message AUthentication Code
Message AUthentication CodeMessage AUthentication Code
Message AUthentication Code
Keval Bhogayata
 
Citation of Paper on "Troubleshooting software configurations"
Citation of Paper on "Troubleshooting software configurations"Citation of Paper on "Troubleshooting software configurations"
Citation of Paper on "Troubleshooting software configurations"
Keval Bhogayata
 
Holography through walls using Wi-fi
Holography through walls using Wi-fiHolography through walls using Wi-fi
Holography through walls using Wi-fi
Keval Bhogayata
 
Cryptolocker Ransomware Attack
Cryptolocker Ransomware AttackCryptolocker Ransomware Attack
Cryptolocker Ransomware Attack
Keval Bhogayata
 
Flow of Communication
Flow of CommunicationFlow of Communication
Flow of Communication
Keval Bhogayata
 
Recruitment Types & Process
Recruitment Types & ProcessRecruitment Types & Process
Recruitment Types & Process
Keval Bhogayata
 
Banking process gujarati
Banking process   gujaratiBanking process   gujarati
Banking process gujarati
Keval Bhogayata
 

More from Keval Bhogayata (7)

Message AUthentication Code
Message AUthentication CodeMessage AUthentication Code
Message AUthentication Code
 
Citation of Paper on "Troubleshooting software configurations"
Citation of Paper on "Troubleshooting software configurations"Citation of Paper on "Troubleshooting software configurations"
Citation of Paper on "Troubleshooting software configurations"
 
Holography through walls using Wi-fi
Holography through walls using Wi-fiHolography through walls using Wi-fi
Holography through walls using Wi-fi
 
Cryptolocker Ransomware Attack
Cryptolocker Ransomware AttackCryptolocker Ransomware Attack
Cryptolocker Ransomware Attack
 
Flow of Communication
Flow of CommunicationFlow of Communication
Flow of Communication
 
Recruitment Types & Process
Recruitment Types & ProcessRecruitment Types & Process
Recruitment Types & Process
 
Banking process gujarati
Banking process   gujaratiBanking process   gujarati
Banking process gujarati
 

Recently uploaded

一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
GetInData
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
mzpolocfi
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 

Recently uploaded (20)

一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 

Insertion in singly linked list

  • 1. Insertion in Singly Linked List
  • 2. Linked List • What is a Linked List? Linked List is a data structure. It is collection of nodes. Linked List is used widely because it do not need continue memory slot, because the data stored in linked list is accessed through ‘Links’.
  • 3. Singly Linked List In a singly linked list node includes a ‘data’ part and a ‘link’ part. Node : Data: It includes any information that is to be stored. Link: It have the address of the next consecutive node. Data Link
  • 4. Insertion (1) Data Structures are used so that a data can be easily modified and accessed. (2) This modification includes: Insertion, Updating of Value, Delete and some other special operations. (3) Insertion is needed in a data structure for adding a value or information while making it first time or it can also take place after it has been made once completely. That is why insertion may happen in any part of the data structure: At First, At Middle or At Last.
  • 5. Insertion in Singly Linked List • Insertion in Singly Linked list is quite convenient in compare to array like structure. • In a structure like array a number of shifts may take place which is not at all acceptable. • In a Singly Linked List only swap of two links are needed for single insertion. • We have discussed Insertion at first, at middle and at last in the singly linked list.
  • 6. Node creation • For insertion first we have to create a new node and for creating a new node we have to find whether required space is available or not. • For doing so: Say AVAIL=‘Pointer showing Available Space’ If(AVAIL==NULL) Output: Space not available Else : New node gets available space and AVAIL shifts to next available free space if it exists.
  • 7. ‘Data’ and ‘Link’ part of New Node • After space allocation to the New Node. The ‘Data’ Part is given the desired value & The ‘Link’ Part have initially NULL value. After the insertion of node in the singly linked list the ‘Link’ part is updated accordingly.
  • 8. Insertion at First For insertion at first the New Node should point to the first node (before insertion) and start should point to the New Node. For doing so: New_Node -> Link = Start; Start = New_node;
  • 9. Insertion at Middle For insertion at Middle the New Node should point to the node next to it and the previous node should point to the New Node. For doing so: New_Node -> Link = Previous_node -> Link Previous_node -> Link = New_node;
  • 10. Insertion at Last For Insertion at last the last node (before insertion) should point the New Node and the ‘Link’ part of New Node must be NULL. For doing so: Last_Node -> Link = New_node;
  • 11. Traversal For Insertion at Middle and Insertion at Last we have to traverse till previous and last node respectively. To reach till desired Node we have to stop the traversal at some specific point. To do this we have to ask user whether he wants insertion before or after specific value OR before or after specific position.
  • 12. Conditions Condition to stop traversal at desired point * Initialize Count with 1. # PTR =Pointer that is traversing. Before given value (PTR -> Next) -> Data = ‘Value’ [#] After given value PTR -> Data = ‘Value’ [#] Before given position Count == ‘Position’ – 1 [*] After given position Count == ‘Position’ [*]
  • 13. Process Summary (1) Create a New Node (2) Apply values to the ‘Data’ and ‘Link’ part. [Link part is NULL initially] (3) Traverse in the linked list until we reach to the desired point. (4) Insert Node using swaps of links.