SlideShare a Scribd company logo
/*
* C++ Program to Implement Doubly Linked List
*/
#include
#include
#include
/*
* Node Declaration
*/
using namespace std;
struct node
{
int info;
struct node *next;
struct node *prev;
}*head;
/*
Class Declaration
*/
class dll
{
public:
void create(int value);
void append(int value);
void insert(int value, int index);
void del(int value);
void display();
dll()
{
head = NULL;
}
/* destructor*/
~dll()
{
node *ptr;
ptr = head;
while(ptr!=0){
node *next = ptr->next;
delete ptr;
ptr = next;
}
}
};
/*
* Main: Conatins Menu
*/
int main()
{
int option, element, index;
dll dl;
while (1)
{
cout<>option;
switch ( option )
{
case 1:
cout<<"Enter the element: ";
cin>>element;
dl.create(element);
cout<>element;
dl.append(element);
cout<>element;
cout<<"Insert Element after postion: ";
cin>>index;
dl.insert(element, index);
cout<>element;
dl.del(element);
cout<info = value;
temp->next = NULL;
if (head == NULL)
{
temp->prev = NULL;
head = temp;
}
else
{
s = head;
while (s->next != NULL)
s = s->next;
s->next = temp;
temp->prev = s;
}
}
/*
* Insertion at the beginning
*/
void dll::append(int value)
{
if (head == NULL)
{
cout<<"First Create the list."<prev = NULL;
temp->info = value;
temp->next = head;
head->prev = temp;
head = temp;
cout<<"Element Inserted"<next;
if (q == NULL)
{
cout<<"There are less than ";
cout<info = value;
if (q->next == NULL)
{
q->next = tmp;
tmp->next = NULL;
tmp->prev = q;
}
else
{
tmp->next = q->next;
tmp->next->prev = tmp;
q->next = tmp;
tmp->prev = q;
}
cout<<"Element Inserted"<info == value)
{
tmp = head;
head = head->next;
head->prev = NULL;
cout<<"Element Deleted"<next->next != NULL)
{
/*Element deleted in between*/
if (q->next->info == value)
{
tmp = q->next;
q->next = tmp->next;
tmp->next->prev = q;
cout<<"Element Deleted"<next;
}
/*last element deleted*/
if (q->next->info == value)
{
tmp = q->next;
free(tmp);
q->next = NULL;
cout<<"Element Deleted"<info<<" <-> ";
q = q->next;
}
cout<<"NULL"<
Solution
/*
* C++ Program to Implement Doubly Linked List
*/
#include
#include
#include
/*
* Node Declaration
*/
using namespace std;
struct node
{
int info;
struct node *next;
struct node *prev;
}*head;
/*
Class Declaration
*/
class dll
{
public:
void create(int value);
void append(int value);
void insert(int value, int index);
void del(int value);
void display();
dll()
{
head = NULL;
}
/* destructor*/
~dll()
{
node *ptr;
ptr = head;
while(ptr!=0){
node *next = ptr->next;
delete ptr;
ptr = next;
}
}
};
/*
* Main: Conatins Menu
*/
int main()
{
int option, element, index;
dll dl;
while (1)
{
cout<>option;
switch ( option )
{
case 1:
cout<<"Enter the element: ";
cin>>element;
dl.create(element);
cout<>element;
dl.append(element);
cout<>element;
cout<<"Insert Element after postion: ";
cin>>index;
dl.insert(element, index);
cout<>element;
dl.del(element);
cout<info = value;
temp->next = NULL;
if (head == NULL)
{
temp->prev = NULL;
head = temp;
}
else
{
s = head;
while (s->next != NULL)
s = s->next;
s->next = temp;
temp->prev = s;
}
}
/*
* Insertion at the beginning
*/
void dll::append(int value)
{
if (head == NULL)
{
cout<<"First Create the list."<prev = NULL;
temp->info = value;
temp->next = head;
head->prev = temp;
head = temp;
cout<<"Element Inserted"<next;
if (q == NULL)
{
cout<<"There are less than ";
cout<info = value;
if (q->next == NULL)
{
q->next = tmp;
tmp->next = NULL;
tmp->prev = q;
}
else
{
tmp->next = q->next;
tmp->next->prev = tmp;
q->next = tmp;
tmp->prev = q;
}
cout<<"Element Inserted"<info == value)
{
tmp = head;
head = head->next;
head->prev = NULL;
cout<<"Element Deleted"<next->next != NULL)
{
/*Element deleted in between*/
if (q->next->info == value)
{
tmp = q->next;
q->next = tmp->next;
tmp->next->prev = q;
cout<<"Element Deleted"<next;
}
/*last element deleted*/
if (q->next->info == value)
{
tmp = q->next;
free(tmp);
q->next = NULL;
cout<<"Element Deleted"<info<<" <-> ";
q = q->next;
}
cout<<"NULL"<

More Related Content

Similar to C++ Program to Implement Doubly Linked List #includei.pdf

take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
fastechsrv
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
Sourav Gayen
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Abu Saleh
 
using set identitiesSolutionimport java.util.Scanner; c.pdf
using set identitiesSolutionimport java.util.Scanner;  c.pdfusing set identitiesSolutionimport java.util.Scanner;  c.pdf
using set identitiesSolutionimport java.util.Scanner; c.pdf
excellentmobilesabc
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdfConsider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
bharatchawla141
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
DaniyalAli81
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
clarkjanyce
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
connellalykshamesb60
 
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
formicreation
 
File Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdfFile Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdf
footworld1
 
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
BrianGHiNewmanv
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
harihelectronicspune
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
fantoosh1
 
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
arpitcomputronics
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
aashisha5
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
saradashata
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
anwarsadath111
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
deepua8
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
KamalSaini561034
 

Similar to C++ Program to Implement Doubly Linked List #includei.pdf (20)

take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
using set identitiesSolutionimport java.util.Scanner; c.pdf
using set identitiesSolutionimport java.util.Scanner;  c.pdfusing set identitiesSolutionimport java.util.Scanner;  c.pdf
using set identitiesSolutionimport java.util.Scanner; c.pdf
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdfConsider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
There are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docxThere are a number of errors in the following program- All errors are.docx
There are a number of errors in the following program- All errors are.docx
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
 
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
 
File Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdfFile Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.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
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
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
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 

More from Lalkamal2

steps are as follows Dissolve the (pressumably.pdf
                     steps are as follows   Dissolve the (pressumably.pdf                     steps are as follows   Dissolve the (pressumably.pdf
steps are as follows Dissolve the (pressumably.pdf
Lalkamal2
 
the two features of the asynchronus connection that allow the receiv.pdf
the two features of the asynchronus connection that allow the receiv.pdfthe two features of the asynchronus connection that allow the receiv.pdf
the two features of the asynchronus connection that allow the receiv.pdf
Lalkamal2
 
Telomerase is the enzyme responsible for maintenance of the length o.pdf
Telomerase is the enzyme responsible for maintenance of the length o.pdfTelomerase is the enzyme responsible for maintenance of the length o.pdf
Telomerase is the enzyme responsible for maintenance of the length o.pdf
Lalkamal2
 
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdfSuppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
Lalkamal2
 
probablity = 212 100 = 16.6 Solutionprobablity = 212 10.pdf
probablity = 212  100 = 16.6 Solutionprobablity = 212  10.pdfprobablity = 212  100 = 16.6 Solutionprobablity = 212  10.pdf
probablity = 212 100 = 16.6 Solutionprobablity = 212 10.pdf
Lalkamal2
 
Platinum complexes like Asplastin are powerful antitumor medications.pdf
Platinum complexes like Asplastin are powerful antitumor medications.pdfPlatinum complexes like Asplastin are powerful antitumor medications.pdf
Platinum complexes like Asplastin are powerful antitumor medications.pdf
Lalkamal2
 
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdfPart 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
Lalkamal2
 
none of them are correct!Solutionnone of them are correct!.pdf
none of them are correct!Solutionnone of them are correct!.pdfnone of them are correct!Solutionnone of them are correct!.pdf
none of them are correct!Solutionnone of them are correct!.pdf
Lalkamal2
 
notor^Solutionnotor^.pdf
notor^Solutionnotor^.pdfnotor^Solutionnotor^.pdf
notor^Solutionnotor^.pdf
Lalkamal2
 
Negative control plate with no DNA transforms competent cells withou.pdf
Negative control plate with no DNA transforms competent cells withou.pdfNegative control plate with no DNA transforms competent cells withou.pdf
Negative control plate with no DNA transforms competent cells withou.pdf
Lalkamal2
 
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdfModifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
Lalkamal2
 
Message types used by the DHCP boot sequenceop Message type.h.pdf
Message types used by the DHCP boot sequenceop Message type.h.pdfMessage types used by the DHCP boot sequenceop Message type.h.pdf
Message types used by the DHCP boot sequenceop Message type.h.pdf
Lalkamal2
 
Law of conservation of matter(mass)In any closed system subjected .pdf
Law of conservation of matter(mass)In any closed system subjected .pdfLaw of conservation of matter(mass)In any closed system subjected .pdf
Law of conservation of matter(mass)In any closed system subjected .pdf
Lalkamal2
 
It is a unit of measurement for the amount of substance.The mole is .pdf
It is a unit of measurement for the amount of substance.The mole is .pdfIt is a unit of measurement for the amount of substance.The mole is .pdf
It is a unit of measurement for the amount of substance.The mole is .pdf
Lalkamal2
 
In insurance, the term risk pooling refers to the spreading of f.pdf
In insurance, the term risk pooling refers to the spreading of f.pdfIn insurance, the term risk pooling refers to the spreading of f.pdf
In insurance, the term risk pooling refers to the spreading of f.pdf
Lalkamal2
 
Some CO is Added The Pressure of CH4 and H2O will.pdf
                     Some CO is Added The Pressure of CH4 and H2O will.pdf                     Some CO is Added The Pressure of CH4 and H2O will.pdf
Some CO is Added The Pressure of CH4 and H2O will.pdf
Lalkamal2
 
dasSolutiondas.pdf
dasSolutiondas.pdfdasSolutiondas.pdf
dasSolutiondas.pdf
Lalkamal2
 
Comments Figures are not properly numbered. Further signal of figur.pdf
Comments Figures are not properly numbered. Further signal of figur.pdfComments Figures are not properly numbered. Further signal of figur.pdf
Comments Figures are not properly numbered. Further signal of figur.pdf
Lalkamal2
 
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdfChange the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
Lalkamal2
 
Balance sheetBalance sheet is the statement of financial position .pdf
Balance sheetBalance sheet is the statement of financial position .pdfBalance sheetBalance sheet is the statement of financial position .pdf
Balance sheetBalance sheet is the statement of financial position .pdf
Lalkamal2
 

More from Lalkamal2 (20)

steps are as follows Dissolve the (pressumably.pdf
                     steps are as follows   Dissolve the (pressumably.pdf                     steps are as follows   Dissolve the (pressumably.pdf
steps are as follows Dissolve the (pressumably.pdf
 
the two features of the asynchronus connection that allow the receiv.pdf
the two features of the asynchronus connection that allow the receiv.pdfthe two features of the asynchronus connection that allow the receiv.pdf
the two features of the asynchronus connection that allow the receiv.pdf
 
Telomerase is the enzyme responsible for maintenance of the length o.pdf
Telomerase is the enzyme responsible for maintenance of the length o.pdfTelomerase is the enzyme responsible for maintenance of the length o.pdf
Telomerase is the enzyme responsible for maintenance of the length o.pdf
 
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdfSuppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
Suppose Bob sends an encrypted document to Alice. To be verifiable, .pdf
 
probablity = 212 100 = 16.6 Solutionprobablity = 212 10.pdf
probablity = 212  100 = 16.6 Solutionprobablity = 212  10.pdfprobablity = 212  100 = 16.6 Solutionprobablity = 212  10.pdf
probablity = 212 100 = 16.6 Solutionprobablity = 212 10.pdf
 
Platinum complexes like Asplastin are powerful antitumor medications.pdf
Platinum complexes like Asplastin are powerful antitumor medications.pdfPlatinum complexes like Asplastin are powerful antitumor medications.pdf
Platinum complexes like Asplastin are powerful antitumor medications.pdf
 
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdfPart 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
Part 1 1)#include stdio.hint testWhileLoop() ; int testFo.pdf
 
none of them are correct!Solutionnone of them are correct!.pdf
none of them are correct!Solutionnone of them are correct!.pdfnone of them are correct!Solutionnone of them are correct!.pdf
none of them are correct!Solutionnone of them are correct!.pdf
 
notor^Solutionnotor^.pdf
notor^Solutionnotor^.pdfnotor^Solutionnotor^.pdf
notor^Solutionnotor^.pdf
 
Negative control plate with no DNA transforms competent cells withou.pdf
Negative control plate with no DNA transforms competent cells withou.pdfNegative control plate with no DNA transforms competent cells withou.pdf
Negative control plate with no DNA transforms competent cells withou.pdf
 
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdfModifications highlighted in bold lettersDropOutStack.javaim.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
 
Message types used by the DHCP boot sequenceop Message type.h.pdf
Message types used by the DHCP boot sequenceop Message type.h.pdfMessage types used by the DHCP boot sequenceop Message type.h.pdf
Message types used by the DHCP boot sequenceop Message type.h.pdf
 
Law of conservation of matter(mass)In any closed system subjected .pdf
Law of conservation of matter(mass)In any closed system subjected .pdfLaw of conservation of matter(mass)In any closed system subjected .pdf
Law of conservation of matter(mass)In any closed system subjected .pdf
 
It is a unit of measurement for the amount of substance.The mole is .pdf
It is a unit of measurement for the amount of substance.The mole is .pdfIt is a unit of measurement for the amount of substance.The mole is .pdf
It is a unit of measurement for the amount of substance.The mole is .pdf
 
In insurance, the term risk pooling refers to the spreading of f.pdf
In insurance, the term risk pooling refers to the spreading of f.pdfIn insurance, the term risk pooling refers to the spreading of f.pdf
In insurance, the term risk pooling refers to the spreading of f.pdf
 
Some CO is Added The Pressure of CH4 and H2O will.pdf
                     Some CO is Added The Pressure of CH4 and H2O will.pdf                     Some CO is Added The Pressure of CH4 and H2O will.pdf
Some CO is Added The Pressure of CH4 and H2O will.pdf
 
dasSolutiondas.pdf
dasSolutiondas.pdfdasSolutiondas.pdf
dasSolutiondas.pdf
 
Comments Figures are not properly numbered. Further signal of figur.pdf
Comments Figures are not properly numbered. Further signal of figur.pdfComments Figures are not properly numbered. Further signal of figur.pdf
Comments Figures are not properly numbered. Further signal of figur.pdf
 
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdfChange the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
Change the value of jug1 and jug 2 accordingly. 1 File WaterJugBSF.j.pdf
 
Balance sheetBalance sheet is the statement of financial position .pdf
Balance sheetBalance sheet is the statement of financial position .pdfBalance sheetBalance sheet is the statement of financial position .pdf
Balance sheetBalance sheet is the statement of financial position .pdf
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 

C++ Program to Implement Doubly Linked List #includei.pdf

  • 1. /* * C++ Program to Implement Doubly Linked List */ #include #include #include /* * Node Declaration */ using namespace std; struct node { int info; struct node *next; struct node *prev; }*head; /* Class Declaration */ class dll { public: void create(int value); void append(int value); void insert(int value, int index); void del(int value); void display(); dll() { head = NULL; } /* destructor*/ ~dll() { node *ptr;
  • 2. ptr = head; while(ptr!=0){ node *next = ptr->next; delete ptr; ptr = next; } } }; /* * Main: Conatins Menu */ int main() { int option, element, index; dll dl; while (1) { cout<>option; switch ( option ) { case 1: cout<<"Enter the element: "; cin>>element; dl.create(element); cout<>element; dl.append(element); cout<>element; cout<<"Insert Element after postion: "; cin>>index; dl.insert(element, index); cout<>element; dl.del(element); cout<info = value; temp->next = NULL; if (head == NULL) {
  • 3. temp->prev = NULL; head = temp; } else { s = head; while (s->next != NULL) s = s->next; s->next = temp; temp->prev = s; } } /* * Insertion at the beginning */ void dll::append(int value) { if (head == NULL) { cout<<"First Create the list."<prev = NULL; temp->info = value; temp->next = head; head->prev = temp; head = temp; cout<<"Element Inserted"<next; if (q == NULL) { cout<<"There are less than "; cout<info = value; if (q->next == NULL) { q->next = tmp; tmp->next = NULL; tmp->prev = q; } else
  • 4. { tmp->next = q->next; tmp->next->prev = tmp; q->next = tmp; tmp->prev = q; } cout<<"Element Inserted"<info == value) { tmp = head; head = head->next; head->prev = NULL; cout<<"Element Deleted"<next->next != NULL) { /*Element deleted in between*/ if (q->next->info == value) { tmp = q->next; q->next = tmp->next; tmp->next->prev = q; cout<<"Element Deleted"<next; } /*last element deleted*/ if (q->next->info == value) { tmp = q->next; free(tmp); q->next = NULL; cout<<"Element Deleted"<info<<" <-> "; q = q->next; } cout<<"NULL"< Solution /* * C++ Program to Implement Doubly Linked List */
  • 5. #include #include #include /* * Node Declaration */ using namespace std; struct node { int info; struct node *next; struct node *prev; }*head; /* Class Declaration */ class dll { public: void create(int value); void append(int value); void insert(int value, int index); void del(int value); void display(); dll() { head = NULL; } /* destructor*/ ~dll() { node *ptr; ptr = head; while(ptr!=0){ node *next = ptr->next; delete ptr;
  • 6. ptr = next; } } }; /* * Main: Conatins Menu */ int main() { int option, element, index; dll dl; while (1) { cout<>option; switch ( option ) { case 1: cout<<"Enter the element: "; cin>>element; dl.create(element); cout<>element; dl.append(element); cout<>element; cout<<"Insert Element after postion: "; cin>>index; dl.insert(element, index); cout<>element; dl.del(element); cout<info = value; temp->next = NULL; if (head == NULL) { temp->prev = NULL; head = temp; } else
  • 7. { s = head; while (s->next != NULL) s = s->next; s->next = temp; temp->prev = s; } } /* * Insertion at the beginning */ void dll::append(int value) { if (head == NULL) { cout<<"First Create the list."<prev = NULL; temp->info = value; temp->next = head; head->prev = temp; head = temp; cout<<"Element Inserted"<next; if (q == NULL) { cout<<"There are less than "; cout<info = value; if (q->next == NULL) { q->next = tmp; tmp->next = NULL; tmp->prev = q; } else { tmp->next = q->next; tmp->next->prev = tmp; q->next = tmp;
  • 8. tmp->prev = q; } cout<<"Element Inserted"<info == value) { tmp = head; head = head->next; head->prev = NULL; cout<<"Element Deleted"<next->next != NULL) { /*Element deleted in between*/ if (q->next->info == value) { tmp = q->next; q->next = tmp->next; tmp->next->prev = q; cout<<"Element Deleted"<next; } /*last element deleted*/ if (q->next->info == value) { tmp = q->next; free(tmp); q->next = NULL; cout<<"Element Deleted"<info<<" <-> "; q = q->next; } cout<<"NULL"<