SlideShare ist ein Scribd-Unternehmen logo
1 von 15
1-1
Link List
Definition:
A link list is a linear collection of data element,
called nodes. The linear order is given by pointers.
Each node is divided into two or more parts.
Types of link list:
1.Singly link list.
2.Circular link list.
3.Doubly link list.
4.Doubly circular link list.
4-2
Link List
Advantages:
1. Link list are dynamic data structure.
2. Efficient memory utilization.
3. Insertion and deletion are easier.
Disadvantages:
1. If the number of fields are more then more memory
space is needed.
2. Access to an data item is little bit time consuming.
4-3
Singly-link list
Singly link list:
A singly link list is one in which all nodes are
linked together in some sequential manner. Hence, it is
also called linear linked list. It contains mainly two
parts.
1.Data part .
2.Address part(next).
Example : We have three node as shown in figure:
Data DataDataNext Next Next
Node 1 Node 2 Node 3
NULL
Head Tail
4-4
Singly-link list
Insertion in the Singly link list
1.Insertion at beginning:-
Logic:
1.temp->next=head.
2.head=temp.
10 200 3020 300 NULL
100 200 300
Head Tail
5
Temp
50
New node
100
4-5
Singly-link list
Insertion in the Singly link list
1.Insertion at Middle:-
Important terms:
1.Cur=head.
2.Specify position…lets 3rd
.
3.Take variable i=1.
10 200 3020 300 NULL
200 300
Head Tail
5
Temp
50
New node
100
while(pos!=i+1)
{
cur=cur->next;
i++;
}
4-6
Singly-link list
Insertion in the Singly link list
1.Insertion at Middle:-
Looping:
10 200 3020 300 NULL
200 300
Head Tail
5
Temp
50
New node
100
1st
.pos==3&&i== 2.
condition true
cur=cur->next &&
increase I with 1.
2nd
.pos==3&&i==3
condition false
exit from loop.
Cur
4-7
Singly-link list
Insertion in the Singly link list
1.Insertion at Middle:-
Logic:
1.temp->next=cur->next.
2.cur->next=temp.
10 200 3020 300 NULL
200 300
Head Tail
5
Temp
50
100
Cur
300
50
4-8
Singly-link list
Insertion in the Singly link list
1.Insertion at End:-
Logic:
1.tail->next=temp.
2.tail=temp.
3.tail->next=NULL.
10 200 3020 300 NULL
200 300
Head Tail
5
Temp
50
New node
100 50
NULL
4-9
Singly-link list
Deletion in the Singly link list
1.Deletion at Begin:-
Logic:
1.temp=head.
2.head=head->next.
3.free(temp).
10 200 3020 300 50
200 300
Head Tail
5
50100 50
NULL
Want to delete
Temp HeadHead
4-10
Singly-link list
Deletion in the Singly link list
1.Deletion at Middle:-
Important Terms:
1.Specify variables pos & i=1
2.Take cur=head & Temp.
3.Start looping.
10 200 3020 300 50
200 300
Head Tail
5
50100 50
NULL
Want to delete
Head
while(pos!=i+1)
{
cur=cur->next;
i++;
}
Cur
4-11
Singly-link list
Deletion in the Singly link list
1.Deletion at Middle:-
Logic:
1.if(pos==i++).
2.temp=cur->next.
3.cur->next=temp->next.
4.free(temp).
10 200 3020 300
200 300
Head Tail
5
50100 50
NULL
Want to delete
Head Cur Temp
50
50
4-12
Circular-link list
Circular link list:
A circular link list is just like a singly link list
but the difference is that the last node of the circular
link list will contains that address of first node. It will
also contains tow parts.
1.Data part .
2.Address part(next).
Example : We have three node as shown in figure:
Data DataDataNext Next Next
Node 1 Node 2 Node 3
Head Tail
4-13
Doubly Circular
Doubly circular link list:
A doubly circular link list is that whose last node contains
the address of first node and the first node contains the
address of last node. It contains three parts.
1.Data
2.Address of previous node(prev).
3.Address of next node(next).
Example: We have three node as shown in figure:
Node 1
prev Data Next prev Data Next
Node 2
prev Data Next
Node 3
Head Tail
Link list(Doubly Circular)
• Insertion at beginning & at end in D circular
1.Insertion at beginning:
Logic:
1. Temp->next=head.
2. Temp->prev=head->prev.
3. head=Temp.
4. Tail->next=head;
4-14
300 10
100 200 300
200 100 20 300 200 30 1005
New node
Head Tail
50
Temp
100300 50 50
Link list(Doubly Circular)
2.Insertion at End:
Logic:
1. temp->next=tail->next
2. tail->next=temp.
3. temp->prev=tail.
7. tail=temp.
8. head->prev=tail.
4-15
10
100
200
300200
10020300 200 30300100
Head Tail
40
Temp
New node
100
400
400 300
Tail
400

Weitere ähnliche Inhalte

Was ist angesagt?

linked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutoriallinked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy TutorialAfzal Badshah
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiSowmya Jyothi
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queueRai University
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked listVivek Bhargav
 
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMARDOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMARPrasunKumar38
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search treeKrish_ver2
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and searchEstiak Khan
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked ListsAfaq Mansoor Khan
 
Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)shah alom
 
Circular linked list
Circular linked listCircular linked list
Circular linked listchauhankapil
 
Stack application
Stack applicationStack application
Stack applicationStudent
 
Beginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdfBeginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdfAkhileshKumar436707
 

Was ist angesagt? (20)

Queues in C++
Queues in C++Queues in C++
Queues in C++
 
linked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutoriallinked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutorial
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Linked list
Linked listLinked list
Linked list
 
Python array
Python arrayPython array
Python array
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMARDOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
DOUBLE LINKED LIST(DATA STRUCTURE) PPT BY PRASUN KUMAR
 
Linked List
Linked ListLinked List
Linked List
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Linklist
LinklistLinklist
Linklist
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and search
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Stack application
Stack applicationStack application
Stack application
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Beginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdfBeginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdf
 

Andere mochten auch

Circular linked list
Circular linked listCircular linked list
Circular linked listdchuynh
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked listsstudent
 
Link list CSE ( Data structure ) .
Link list CSE  ( Data structure ) .Link list CSE  ( Data structure ) .
Link list CSE ( Data structure ) .Nirjhor003
 
Linked list without animation
Linked list without animationLinked list without animation
Linked list without animationLovelyn Rose
 
Link list(by harshit)
Link list(by harshit)Link list(by harshit)
Link list(by harshit)Harshit Jain
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked listFahd Allebdi
 

Andere mochten auch (9)

Circular linked list
Circular linked listCircular linked list
Circular linked list
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 
Link list CSE ( Data structure ) .
Link list CSE  ( Data structure ) .Link list CSE  ( Data structure ) .
Link list CSE ( Data structure ) .
 
Linked List
Linked ListLinked List
Linked List
 
Singly link list
Singly link listSingly link list
Singly link list
 
Linked list without animation
Linked list without animationLinked list without animation
Linked list without animation
 
Link list(by harshit)
Link list(by harshit)Link list(by harshit)
Link list(by harshit)
 
circular linked list
circular linked listcircular linked list
circular linked list
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 

Ähnlich wie Link list

Ähnlich wie Link list (20)

Linked List
Linked ListLinked List
Linked List
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
Linked lists
Linked listsLinked lists
Linked lists
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
 
Linked List Presentation in data structurepptx
Linked List Presentation in data structurepptxLinked List Presentation in data structurepptx
Linked List Presentation in data structurepptx
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
 
Linkedlists
LinkedlistsLinkedlists
Linkedlists
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
 
Linked Lists.pdf
Linked Lists.pdfLinked Lists.pdf
Linked Lists.pdf
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
 
module 3-.pptx
module 3-.pptxmodule 3-.pptx
module 3-.pptx
 
Link list assi
Link list assiLink list assi
Link list assi
 
Linked list
Linked listLinked list
Linked list
 
Linked List
Linked ListLinked List
Linked List
 
Team 10
Team 10Team 10
Team 10
 
02. the linked lists (1)
02. the linked lists (1)02. the linked lists (1)
02. the linked lists (1)
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 

Kürzlich hochgeladen

The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 

Kürzlich hochgeladen (20)

The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 

Link list

  • 1. 1-1 Link List Definition: A link list is a linear collection of data element, called nodes. The linear order is given by pointers. Each node is divided into two or more parts. Types of link list: 1.Singly link list. 2.Circular link list. 3.Doubly link list. 4.Doubly circular link list.
  • 2. 4-2 Link List Advantages: 1. Link list are dynamic data structure. 2. Efficient memory utilization. 3. Insertion and deletion are easier. Disadvantages: 1. If the number of fields are more then more memory space is needed. 2. Access to an data item is little bit time consuming.
  • 3. 4-3 Singly-link list Singly link list: A singly link list is one in which all nodes are linked together in some sequential manner. Hence, it is also called linear linked list. It contains mainly two parts. 1.Data part . 2.Address part(next). Example : We have three node as shown in figure: Data DataDataNext Next Next Node 1 Node 2 Node 3 NULL Head Tail
  • 4. 4-4 Singly-link list Insertion in the Singly link list 1.Insertion at beginning:- Logic: 1.temp->next=head. 2.head=temp. 10 200 3020 300 NULL 100 200 300 Head Tail 5 Temp 50 New node 100
  • 5. 4-5 Singly-link list Insertion in the Singly link list 1.Insertion at Middle:- Important terms: 1.Cur=head. 2.Specify position…lets 3rd . 3.Take variable i=1. 10 200 3020 300 NULL 200 300 Head Tail 5 Temp 50 New node 100 while(pos!=i+1) { cur=cur->next; i++; }
  • 6. 4-6 Singly-link list Insertion in the Singly link list 1.Insertion at Middle:- Looping: 10 200 3020 300 NULL 200 300 Head Tail 5 Temp 50 New node 100 1st .pos==3&&i== 2. condition true cur=cur->next && increase I with 1. 2nd .pos==3&&i==3 condition false exit from loop. Cur
  • 7. 4-7 Singly-link list Insertion in the Singly link list 1.Insertion at Middle:- Logic: 1.temp->next=cur->next. 2.cur->next=temp. 10 200 3020 300 NULL 200 300 Head Tail 5 Temp 50 100 Cur 300 50
  • 8. 4-8 Singly-link list Insertion in the Singly link list 1.Insertion at End:- Logic: 1.tail->next=temp. 2.tail=temp. 3.tail->next=NULL. 10 200 3020 300 NULL 200 300 Head Tail 5 Temp 50 New node 100 50 NULL
  • 9. 4-9 Singly-link list Deletion in the Singly link list 1.Deletion at Begin:- Logic: 1.temp=head. 2.head=head->next. 3.free(temp). 10 200 3020 300 50 200 300 Head Tail 5 50100 50 NULL Want to delete Temp HeadHead
  • 10. 4-10 Singly-link list Deletion in the Singly link list 1.Deletion at Middle:- Important Terms: 1.Specify variables pos & i=1 2.Take cur=head & Temp. 3.Start looping. 10 200 3020 300 50 200 300 Head Tail 5 50100 50 NULL Want to delete Head while(pos!=i+1) { cur=cur->next; i++; } Cur
  • 11. 4-11 Singly-link list Deletion in the Singly link list 1.Deletion at Middle:- Logic: 1.if(pos==i++). 2.temp=cur->next. 3.cur->next=temp->next. 4.free(temp). 10 200 3020 300 200 300 Head Tail 5 50100 50 NULL Want to delete Head Cur Temp 50 50
  • 12. 4-12 Circular-link list Circular link list: A circular link list is just like a singly link list but the difference is that the last node of the circular link list will contains that address of first node. It will also contains tow parts. 1.Data part . 2.Address part(next). Example : We have three node as shown in figure: Data DataDataNext Next Next Node 1 Node 2 Node 3 Head Tail
  • 13. 4-13 Doubly Circular Doubly circular link list: A doubly circular link list is that whose last node contains the address of first node and the first node contains the address of last node. It contains three parts. 1.Data 2.Address of previous node(prev). 3.Address of next node(next). Example: We have three node as shown in figure: Node 1 prev Data Next prev Data Next Node 2 prev Data Next Node 3 Head Tail
  • 14. Link list(Doubly Circular) • Insertion at beginning & at end in D circular 1.Insertion at beginning: Logic: 1. Temp->next=head. 2. Temp->prev=head->prev. 3. head=Temp. 4. Tail->next=head; 4-14 300 10 100 200 300 200 100 20 300 200 30 1005 New node Head Tail 50 Temp 100300 50 50
  • 15. Link list(Doubly Circular) 2.Insertion at End: Logic: 1. temp->next=tail->next 2. tail->next=temp. 3. temp->prev=tail. 7. tail=temp. 8. head->prev=tail. 4-15 10 100 200 300200 10020300 200 30300100 Head Tail 40 Temp New node 100 400 400 300 Tail 400