SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Doubly-Linked List
Doubly Linked List 
 In doubly linked list each node contains two points. 
 which points has a reference to both the next point 
and pervious point of node in list. 
 A doubly linked list is a two-way list because one 
can move in either from left to right or from right to 
left
prev next 
Info 
NODE 
Node Data 
 Info : the user’s data. 
 Prev, Next : the address of next and 
previous node in list
Operations on a Doubly linked list 
o Create list. 
o Insert element at beginning in list. 
o Insert element at end in list. 
o Insert element at any place in list. 
o Delete element from the beginning of list. 
o Delete element from the end of list. 
o Delete element from any place from list.
Create doubly linked list 
NULL 
7 X 
X 9 X
Algorithm 
Step 1: [initially list is empty] 
First = NULL 
last = NULL 
Step 2: [allocate space to newly created node] 
new1= create new node 
Step 3: [assign value to information part of node] 
info[new1]= Value 
Step 4: [assign NULL to the address part for the next] 
next[new1]= NULL 
Step 5: [check for list is empty] 
if first =NULL then 
first = new1 
last = new1 
prev[new1]= NULL 
else 
next[last]= new1 
prev[new1]=last 
last=new1 
end if 
Step 6: exit
Insert an element at beginning 
doubly linked list 
We assume linked list 
first last 
7 9 X 
X 2 X
Algorithm 
Step 1: [allocate space to newly created node] 
new1= create new node 
Step 2: [check for free space] 
if new1=NULL then 
Write “Memory full” 
Step 3: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 4: [assign value to information part of node] 
info[new1]= Value 
Step 5: [store the node at first] 
next[new1]= first 
prev[new1]= NULL 
prev[first]= new1 
first=new1 
Step 6: exit
Insert an element at last of 
doubly linked list 
We assume linked list 
first last 
X 2 7 9 
X 4 X
Algorithm 
Step 1: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 2: [allocate space to newly created node] 
new1= create new node 
Step 3: [assign value to information part to node] 
info[new1]= Value 
Step 4: [store the node at last] 
next[new1]= NULL 
next[last]= new1 
prev[new1]= last 
last=new1 
Step 5: exit
Insert an element at Any place 
doubly linked list 
first last 
X 2 7 9 
4 X 
We assume linked list and 
Insert after 7 valued node 
6 
tra 
t1
Algorithm 
Step 1: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 2: [allocate space to newly created node] 
new1= create new node 
Step 3: [read values of information part of new node] 
info[new1]=value 
Step 4: [initialization] 
tra=first 
Step 5: [perform insertion operation] 
repeat through step 7 while tra != NULL
Step 6: if info[tra] =no then 
if tra=last then 
next[tra]=new1 
next[new1]=NULL 
prev[new1]=tra 
last=new1 
else 
t1=next[tra] 
next[tra]=new1 
next[new1]=t1 
prev[t1]=new1 
prev[new1]=tra 
Step 7: [increment temp value] 
tra=next[tra] 
Step 8: exit
Delete an element at beginning 
of doubly linked list 
first last 
X 2 7 9 
4 X 
We assume linked list 
ffirst 
X
Algorithm 
Step 1: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 2: [perform deletion opration] 
if first=last then 
first=NULL 
last=NULL 
free(first) 
else 
ffirst=next[first] 
free(first) 
first=ffirst 
prev[first]=NULL 
end if 
Step 3: exit
Delete an element at last of 
doubly linked list 
first last 
X 2 7 9 
4 X 
We assume linked list 
t 
X
Algorithm 
Step 1: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 2: [perform deletion opration] 
if first=last then 
first=NULL 
last=NULL 
free(first) 
else 
t=prev[last] 
free(last) 
last=t 
next[last]=NULL 
Step 3: exit
Delete an element at any place 
doubly linked list 
We assume linked list and 
Delete 7 valued node 
first last 
X 2 7 9 
4 X 
tra 
t1 
pr1
Algorithm eny delete 
Step 1: [check for list is empty] 
if first=NULL then 
Write “list is empty” 
return 
Step 2: [perform deletion opration] 
if first=last then 
first=NULL 
last=NULL 
free(first) 
Step 3: [initialization] 
tra=first 
Step 4: [perform insertion operation] 
repeat through step 7 while tra != NULL
Step 5: IF info[tra]=number then 
if tra=first then 
ffirst=next[first] 
free(first) 
first=ffirst 
else if tra=first then 
free(last) 
last=pr1 
next[last]=NULL 
else 
t1=next[tra] 
next[pr1]=t1 
prev[t1]=pr1 
free(tra) 
last=t1 
Step 6: [Assign previous value of tra to prev] 
pr1=tra 
Step 7: [increment temp value] 
tra=next[tra] 
Step 8: exit
Doubly Linked List Structure and Common Operations

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 
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
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
Expression trees
Expression treesExpression trees
Expression trees
 
linked list
linked list linked list
linked list
 
Queue
QueueQueue
Queue
 
Linked list
Linked listLinked list
Linked list
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
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
 
Trees
TreesTrees
Trees
 
Linked List
Linked ListLinked List
Linked List
 
Heap sort
Heap sortHeap sort
Heap sort
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 

Ähnlich wie Doubly Linked List Structure and Common Operations

Ähnlich wie Doubly Linked List Structure and Common Operations (20)

Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
 
Ppt of operations on one way link list
Ppt of operations on one way  link listPpt of operations on one way  link list
Ppt of operations on one way link list
 
Ppt of operations on one way link list
Ppt of operations on one way  link listPpt of operations on one way  link list
Ppt of operations on one way link list
 
Sorting
SortingSorting
Sorting
 
Linked list
Linked listLinked list
Linked list
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
Linked list
Linked listLinked list
Linked list
 
linkrd_list.pdf
linkrd_list.pdflinkrd_list.pdf
linkrd_list.pdf
 
Stack q ll algo
Stack q ll algoStack q ll algo
Stack q ll algo
 
5.Linked list
5.Linked list 5.Linked list
5.Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Unit 5 linked list
Unit   5 linked listUnit   5 linked list
Unit 5 linked list
 

Kürzlich hochgeladen

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 

Kürzlich hochgeladen (20)

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 

Doubly Linked List Structure and Common Operations

  • 2. Doubly Linked List  In doubly linked list each node contains two points.  which points has a reference to both the next point and pervious point of node in list.  A doubly linked list is a two-way list because one can move in either from left to right or from right to left
  • 3. prev next Info NODE Node Data  Info : the user’s data.  Prev, Next : the address of next and previous node in list
  • 4. Operations on a Doubly linked list o Create list. o Insert element at beginning in list. o Insert element at end in list. o Insert element at any place in list. o Delete element from the beginning of list. o Delete element from the end of list. o Delete element from any place from list.
  • 5. Create doubly linked list NULL 7 X X 9 X
  • 6. Algorithm Step 1: [initially list is empty] First = NULL last = NULL Step 2: [allocate space to newly created node] new1= create new node Step 3: [assign value to information part of node] info[new1]= Value Step 4: [assign NULL to the address part for the next] next[new1]= NULL Step 5: [check for list is empty] if first =NULL then first = new1 last = new1 prev[new1]= NULL else next[last]= new1 prev[new1]=last last=new1 end if Step 6: exit
  • 7. Insert an element at beginning doubly linked list We assume linked list first last 7 9 X X 2 X
  • 8. Algorithm Step 1: [allocate space to newly created node] new1= create new node Step 2: [check for free space] if new1=NULL then Write “Memory full” Step 3: [check for list is empty] if first=NULL then Write “list is empty” return Step 4: [assign value to information part of node] info[new1]= Value Step 5: [store the node at first] next[new1]= first prev[new1]= NULL prev[first]= new1 first=new1 Step 6: exit
  • 9. Insert an element at last of doubly linked list We assume linked list first last X 2 7 9 X 4 X
  • 10. Algorithm Step 1: [check for list is empty] if first=NULL then Write “list is empty” return Step 2: [allocate space to newly created node] new1= create new node Step 3: [assign value to information part to node] info[new1]= Value Step 4: [store the node at last] next[new1]= NULL next[last]= new1 prev[new1]= last last=new1 Step 5: exit
  • 11. Insert an element at Any place doubly linked list first last X 2 7 9 4 X We assume linked list and Insert after 7 valued node 6 tra t1
  • 12. Algorithm Step 1: [check for list is empty] if first=NULL then Write “list is empty” return Step 2: [allocate space to newly created node] new1= create new node Step 3: [read values of information part of new node] info[new1]=value Step 4: [initialization] tra=first Step 5: [perform insertion operation] repeat through step 7 while tra != NULL
  • 13. Step 6: if info[tra] =no then if tra=last then next[tra]=new1 next[new1]=NULL prev[new1]=tra last=new1 else t1=next[tra] next[tra]=new1 next[new1]=t1 prev[t1]=new1 prev[new1]=tra Step 7: [increment temp value] tra=next[tra] Step 8: exit
  • 14. Delete an element at beginning of doubly linked list first last X 2 7 9 4 X We assume linked list ffirst X
  • 15. Algorithm Step 1: [check for list is empty] if first=NULL then Write “list is empty” return Step 2: [perform deletion opration] if first=last then first=NULL last=NULL free(first) else ffirst=next[first] free(first) first=ffirst prev[first]=NULL end if Step 3: exit
  • 16. Delete an element at last of doubly linked list first last X 2 7 9 4 X We assume linked list t X
  • 17. Algorithm Step 1: [check for list is empty] if first=NULL then Write “list is empty” return Step 2: [perform deletion opration] if first=last then first=NULL last=NULL free(first) else t=prev[last] free(last) last=t next[last]=NULL Step 3: exit
  • 18. Delete an element at any place doubly linked list We assume linked list and Delete 7 valued node first last X 2 7 9 4 X tra t1 pr1
  • 19. Algorithm eny delete Step 1: [check for list is empty] if first=NULL then Write “list is empty” return Step 2: [perform deletion opration] if first=last then first=NULL last=NULL free(first) Step 3: [initialization] tra=first Step 4: [perform insertion operation] repeat through step 7 while tra != NULL
  • 20. Step 5: IF info[tra]=number then if tra=first then ffirst=next[first] free(first) first=ffirst else if tra=first then free(last) last=pr1 next[last]=NULL else t1=next[tra] next[pr1]=t1 prev[t1]=pr1 free(tra) last=t1 Step 6: [Assign previous value of tra to prev] pr1=tra Step 7: [increment temp value] tra=next[tra] Step 8: exit