SlideShare a Scribd company logo
1 of 4
Write a C++ function that delete nodes in a doubly linkedlist.
It should delete all nodes that have that specific value. Finally, return the head of the linkedlist.
node * DN(node *head, int value) {
}
The linkedlist structure:
struct n {
int value;
node *next;
node *previous;
};
Solution
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
/* Link list node */
struct node
{
int data;
struct node* next;
};
/* Function to delete the entire linked list */
void deleteList(struct node** head_ref)
{
/* deref head_ref to get the real head */
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
free(current);
current = next;
}
/* deref head_ref to affect the real head back
in the caller. */
*head_ref = NULL;
}
/* Given a reference (pointer to pointer) to the head
of a list and an int, push a new node on the front
of the list. */
void push(struct node** head_ref, int new_data)
{
/* allocate node */
struct node* new_node =
(struct node*) malloc(sizeof(struct node));
/* put in the data */
new_node->data = new_data;
/* link the old list off the new node */
new_node->next = (*head_ref);
/* move the head to point to the new node */
(*head_ref)Â Â Â = new_node;
}
/* Drier program to test count function*/
int main()
{
/* Start with the empty list */
struct node* head = NULL;
/* Use push() to construct below list
1->12->1->4->1 */
push(&head, 1);
push(&head, 4);
push(&head, 1);
push(&head, 12);
push(&head, 1);
printf(" Deleting linked list");
deleteList(&head);
printf(" Linked list deleted");
}
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx

More Related Content

Similar to Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx

Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfvishalateen
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfarihantelehyb
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfarpitcomputronics
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfanton291
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxtienlivick
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfsales98
 
Use C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdfUse C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdfshalins6
 
1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdfivylinvaydak64229
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxMatthPYNashd
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfthangarajarivukadal
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfrohit219406
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfformicreation
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdffathimahardwareelect
 

Similar to Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx (20)

C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdf
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
Use C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdfUse C++ Write a function to merge two doubly linked lists. The input.pdf
Use C++ Write a function to merge two doubly linked lists. The input.pdf
 
1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
Linked list1.ppt
Linked list1.pptLinked list1.ppt
Linked list1.ppt
 

More from noreendchesterton753

Suppose the population of interest in a particular study is all Queen'.docx
Suppose the population of interest in a particular study is all Queen'.docxSuppose the population of interest in a particular study is all Queen'.docx
Suppose the population of interest in a particular study is all Queen'.docxnoreendchesterton753
 
Suppose the Federal Reserve increases deposits at financial institutio.docx
Suppose the Federal Reserve increases deposits at financial institutio.docxSuppose the Federal Reserve increases deposits at financial institutio.docx
Suppose the Federal Reserve increases deposits at financial institutio.docxnoreendchesterton753
 
Suppose that Edison and Hilary represent the only two consumers of blu.docx
Suppose that Edison and Hilary represent the only two consumers of blu.docxSuppose that Edison and Hilary represent the only two consumers of blu.docx
Suppose that Edison and Hilary represent the only two consumers of blu.docxnoreendchesterton753
 
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docx
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docxSuppose that 42- of Americans are obese- A) If 100 people are randomly.docx
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docxnoreendchesterton753
 
Suppose I am teaching a class and the test comes and goes with two stu.docx
Suppose I am teaching a class and the test comes and goes with two stu.docxSuppose I am teaching a class and the test comes and goes with two stu.docx
Suppose I am teaching a class and the test comes and goes with two stu.docxnoreendchesterton753
 
Suppose an economy is given by the following- Population -274 million.docx
Suppose an economy is given by the following- Population -274 million.docxSuppose an economy is given by the following- Population -274 million.docx
Suppose an economy is given by the following- Population -274 million.docxnoreendchesterton753
 
Suppose a researcher conducted a study examining the effectiveness of.docx
Suppose a researcher conducted a study examining the effectiveness of.docxSuppose a researcher conducted a study examining the effectiveness of.docx
Suppose a researcher conducted a study examining the effectiveness of.docxnoreendchesterton753
 
Supoese you have 'n' different individuals- and all of them to rearran.docx
Supoese you have 'n' different individuals- and all of them to rearran.docxSupoese you have 'n' different individuals- and all of them to rearran.docx
Supoese you have 'n' different individuals- and all of them to rearran.docxnoreendchesterton753
 
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docx
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docxSunspot Beverages- Limited- of Fiji uses the weighted-average method i.docx
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docxnoreendchesterton753
 
Sunland Company has the following data-Compute total manufacturing cos.docx
Sunland Company has the following data-Compute total manufacturing cos.docxSunland Company has the following data-Compute total manufacturing cos.docx
Sunland Company has the following data-Compute total manufacturing cos.docxnoreendchesterton753
 
Successful negotiating includes some kind of manipulation in order to.docx
Successful negotiating includes some kind of manipulation in order to.docxSuccessful negotiating includes some kind of manipulation in order to.docx
Successful negotiating includes some kind of manipulation in order to.docxnoreendchesterton753
 
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docx
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docxSubsidiary holds an allocated net operating loss (NOL) when it leaves.docx
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docxnoreendchesterton753
 
Substances that dissolve readily in water are termed hydrophilic- They.docx
Substances that dissolve readily in water are termed hydrophilic- They.docxSubstances that dissolve readily in water are termed hydrophilic- They.docx
Substances that dissolve readily in water are termed hydrophilic- They.docxnoreendchesterton753
 
subject FASHION The combination of which Roman terms most closely co.docx
subject FASHION   The combination of which Roman terms most closely co.docxsubject FASHION   The combination of which Roman terms most closely co.docx
subject FASHION The combination of which Roman terms most closely co.docxnoreendchesterton753
 
Styling Conventions By only changing the case of some of the letters-.docx
Styling Conventions By only changing the case of some of the letters-.docxStyling Conventions By only changing the case of some of the letters-.docx
Styling Conventions By only changing the case of some of the letters-.docxnoreendchesterton753
 
Students spend an average of $520 each semester on textbooks- Suppose.docx
Students spend an average of $520 each semester on textbooks- Suppose.docxStudents spend an average of $520 each semester on textbooks- Suppose.docx
Students spend an average of $520 each semester on textbooks- Suppose.docxnoreendchesterton753
 
Species interactions determine an organism's fundamental niche- True F.docx
Species interactions determine an organism's fundamental niche- True F.docxSpecies interactions determine an organism's fundamental niche- True F.docx
Species interactions determine an organism's fundamental niche- True F.docxnoreendchesterton753
 
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docx
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docxSpongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docx
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docxnoreendchesterton753
 
SPSS output of a binomial probability distribution with succes probabi.docx
SPSS output of a binomial probability distribution with succes probabi.docxSPSS output of a binomial probability distribution with succes probabi.docx
SPSS output of a binomial probability distribution with succes probabi.docxnoreendchesterton753
 
Starting on the day Holly was born- her mother has invested $30 at the.docx
Starting on the day Holly was born- her mother has invested $30 at the.docxStarting on the day Holly was born- her mother has invested $30 at the.docx
Starting on the day Holly was born- her mother has invested $30 at the.docxnoreendchesterton753
 

More from noreendchesterton753 (20)

Suppose the population of interest in a particular study is all Queen'.docx
Suppose the population of interest in a particular study is all Queen'.docxSuppose the population of interest in a particular study is all Queen'.docx
Suppose the population of interest in a particular study is all Queen'.docx
 
Suppose the Federal Reserve increases deposits at financial institutio.docx
Suppose the Federal Reserve increases deposits at financial institutio.docxSuppose the Federal Reserve increases deposits at financial institutio.docx
Suppose the Federal Reserve increases deposits at financial institutio.docx
 
Suppose that Edison and Hilary represent the only two consumers of blu.docx
Suppose that Edison and Hilary represent the only two consumers of blu.docxSuppose that Edison and Hilary represent the only two consumers of blu.docx
Suppose that Edison and Hilary represent the only two consumers of blu.docx
 
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docx
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docxSuppose that 42- of Americans are obese- A) If 100 people are randomly.docx
Suppose that 42- of Americans are obese- A) If 100 people are randomly.docx
 
Suppose I am teaching a class and the test comes and goes with two stu.docx
Suppose I am teaching a class and the test comes and goes with two stu.docxSuppose I am teaching a class and the test comes and goes with two stu.docx
Suppose I am teaching a class and the test comes and goes with two stu.docx
 
Suppose an economy is given by the following- Population -274 million.docx
Suppose an economy is given by the following- Population -274 million.docxSuppose an economy is given by the following- Population -274 million.docx
Suppose an economy is given by the following- Population -274 million.docx
 
Suppose a researcher conducted a study examining the effectiveness of.docx
Suppose a researcher conducted a study examining the effectiveness of.docxSuppose a researcher conducted a study examining the effectiveness of.docx
Suppose a researcher conducted a study examining the effectiveness of.docx
 
Supoese you have 'n' different individuals- and all of them to rearran.docx
Supoese you have 'n' different individuals- and all of them to rearran.docxSupoese you have 'n' different individuals- and all of them to rearran.docx
Supoese you have 'n' different individuals- and all of them to rearran.docx
 
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docx
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docxSunspot Beverages- Limited- of Fiji uses the weighted-average method i.docx
Sunspot Beverages- Limited- of Fiji uses the weighted-average method i.docx
 
Sunland Company has the following data-Compute total manufacturing cos.docx
Sunland Company has the following data-Compute total manufacturing cos.docxSunland Company has the following data-Compute total manufacturing cos.docx
Sunland Company has the following data-Compute total manufacturing cos.docx
 
Successful negotiating includes some kind of manipulation in order to.docx
Successful negotiating includes some kind of manipulation in order to.docxSuccessful negotiating includes some kind of manipulation in order to.docx
Successful negotiating includes some kind of manipulation in order to.docx
 
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docx
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docxSubsidiary holds an allocated net operating loss (NOL) when it leaves.docx
Subsidiary holds an allocated net operating loss (NOL) when it leaves.docx
 
Substances that dissolve readily in water are termed hydrophilic- They.docx
Substances that dissolve readily in water are termed hydrophilic- They.docxSubstances that dissolve readily in water are termed hydrophilic- They.docx
Substances that dissolve readily in water are termed hydrophilic- They.docx
 
subject FASHION The combination of which Roman terms most closely co.docx
subject FASHION   The combination of which Roman terms most closely co.docxsubject FASHION   The combination of which Roman terms most closely co.docx
subject FASHION The combination of which Roman terms most closely co.docx
 
Styling Conventions By only changing the case of some of the letters-.docx
Styling Conventions By only changing the case of some of the letters-.docxStyling Conventions By only changing the case of some of the letters-.docx
Styling Conventions By only changing the case of some of the letters-.docx
 
Students spend an average of $520 each semester on textbooks- Suppose.docx
Students spend an average of $520 each semester on textbooks- Suppose.docxStudents spend an average of $520 each semester on textbooks- Suppose.docx
Students spend an average of $520 each semester on textbooks- Suppose.docx
 
Species interactions determine an organism's fundamental niche- True F.docx
Species interactions determine an organism's fundamental niche- True F.docxSpecies interactions determine an organism's fundamental niche- True F.docx
Species interactions determine an organism's fundamental niche- True F.docx
 
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docx
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docxSpongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docx
Spongy moths- Lymantria dispar- have four life cycle stages- egg- cate.docx
 
SPSS output of a binomial probability distribution with succes probabi.docx
SPSS output of a binomial probability distribution with succes probabi.docxSPSS output of a binomial probability distribution with succes probabi.docx
SPSS output of a binomial probability distribution with succes probabi.docx
 
Starting on the day Holly was born- her mother has invested $30 at the.docx
Starting on the day Holly was born- her mother has invested $30 at the.docxStarting on the day Holly was born- her mother has invested $30 at the.docx
Starting on the day Holly was born- her mother has invested $30 at the.docx
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx

  • 1. Write a C++ function that delete nodes in a doubly linkedlist. It should delete all nodes that have that specific value. Finally, return the head of the linkedlist. node * DN(node *head, int value) { } The linkedlist structure: struct n { int value; node *next; node *previous; }; Solution #include<stdio.h> #include<stdlib.h> #include<assert.h> /* Link list node */ struct node { int data; struct node* next; }; /* Function to delete the entire linked list */
  • 2. void deleteList(struct node** head_ref) { /* deref head_ref to get the real head */ struct node* current = *head_ref; struct node* next; while (current != NULL) { next = current->next; free(current); current = next; } /* deref head_ref to affect the real head back in the caller. */ *head_ref = NULL; } /* Given a reference (pointer to pointer) to the head of a list and an int, push a new node on the front of the list. */ void push(struct node** head_ref, int new_data) { /* allocate node */ struct node* new_node = (struct node*) malloc(sizeof(struct node));
  • 3. /* put in the data */ new_node->data = new_data; /* link the old list off the new node */ new_node->next = (*head_ref); /* move the head to point to the new node */ (*head_ref)Â Â Â = new_node; } /* Drier program to test count function*/ int main() { /* Start with the empty list */ struct node* head = NULL; /* Use push() to construct below list 1->12->1->4->1 */ push(&head, 1); push(&head, 4); push(&head, 1); push(&head, 12); push(&head, 1); printf(" Deleting linked list"); deleteList(&head); printf(" Linked list deleted"); }