SlideShare a Scribd company logo
–PLS write program in c++ thanx
Linked List Sorting and Reversing
Write a C++ using your own linked list class to manage a list of string elements. Besides the
basic operations expected of a linked list (add an element, remove an element, check for empty
list, report size (number) of elements in the list, and print out the content of the list), the linked
list class also needs to have a method called sort() and a method called reverse() the manipulate
the string elements. The sort method rearranges the elements in the list so they are sorted in
alphabetical order. The reverse method reverses the order of the elements of the list. Do NOT use
recursion to implement either of these operations. pls write program in c++ thanx
Solution
#include
#include
using namespace std;
class Node{ //class node
public:
string data;
Node* next;
void SetData(string aData) { data = aData; };
void SetNext(Node* aNext) { next = aNext; };
};
class List{ //class list
Node *head;
public:
List() { head = NULL; };
void addElement(string data);
void removeElement(string data);
int isEmpty(Node* temp);
int size();
void print();
void sort();
void reverse();
};
int List::isEmpty(Node* temp){ //method to check whether list is empty or not
if(temp!=NULL)
return 1;
else
return 0;
}
void List::addElement(string data){ //method to add
Node* newNode=new Node();
newNode->SetData(data);
newNode->SetNext(NULL);
Node* temp=head;
if(temp!=NULL)
{
while(temp->next!=NULL)
{temp=temp->next;}
temp->next=newNode;
}
else
head=newNode;
}
void List::removeElement(string data){ //method for delete
Node* temp=head;
Node *prev=head;
if(isEmpty(temp)==1)
{//prev=temp;
while(temp!=NULL)
{
if(temp->data==data)
{prev->next=temp->next;
temp->next=NULL;
}
else
{prev=temp;
temp=temp->next;
}
}
}
else
cout<<"Nothing to delete as linked list is empty "<next;
}
}
return count;
}
void List::print(){ //method for print
Node* temp=head;
if(isEmpty(temp)==1){
while(temp!=NULL)
{
cout<data<<" ";
temp=temp->next;
}
}
}
int main()
{
List list;
list.addElement("anshu");
list.addElement("anurag");
list.addElement("how");
list.addElement("are");
list.addElement("you?");
int count=list.size();
cout<<"size of the linked list= "<

More Related Content

Similar to –PLS write program in c++ thanxLinked List Sorting and Reversing.pdf

Data structure
Data  structureData  structure
Data structure
Arvind Kumar
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdf
mayorothenguyenhob69
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
Isaac9LjWelchq
 
Week 2 - Data Structures and Algorithms
Week 2 - Data Structures and AlgorithmsWeek 2 - Data Structures and Algorithms
Week 2 - Data Structures and Algorithms
Ferdin Joe John Joseph PhD
 
12888239 (2).ppt
12888239 (2).ppt12888239 (2).ppt
12888239 (2).ppt
SrinivasanCSE
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
aathiauto
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
ToniyaP1
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
Durga Devi
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
surya pandian
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
pasqualealvarez467
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
swajahatr
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
Swapnil Mishra
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبياناتRafal Edward
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
meenamadhuvandhi2
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdfneed it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
eyeattractionsindia
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdf
info335653
 
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docxAD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AmuthachenthiruK
 

Similar to –PLS write program in c++ thanxLinked List Sorting and Reversing.pdf (20)

Data structure
Data  structureData  structure
Data structure
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdf
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
 
Week 2 - Data Structures and Algorithms
Week 2 - Data Structures and AlgorithmsWeek 2 - Data Structures and Algorithms
Week 2 - Data Structures and Algorithms
 
12888239 (2).ppt
12888239 (2).ppt12888239 (2).ppt
12888239 (2).ppt
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdfneed it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
need it in c++ Task 2 Reuse the Task 1 and create 2 linkedl.pdf
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdf
 
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docxAD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
 

More from poblettesedanoree498

Give examples of two zoonotic diseases. Explain how these zoonotic d.pdf
Give examples of two zoonotic diseases. Explain how these zoonotic d.pdfGive examples of two zoonotic diseases. Explain how these zoonotic d.pdf
Give examples of two zoonotic diseases. Explain how these zoonotic d.pdf
poblettesedanoree498
 
Create the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfCreate the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdf
poblettesedanoree498
 
Describe different flow control valves with figures. Include referenc.pdf
Describe different flow control valves with figures. Include referenc.pdfDescribe different flow control valves with figures. Include referenc.pdf
Describe different flow control valves with figures. Include referenc.pdf
poblettesedanoree498
 
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdfConsider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
poblettesedanoree498
 
Compare and contrast transmit and receive diversity. Describe how ea.pdf
Compare and contrast transmit and receive diversity. Describe how ea.pdfCompare and contrast transmit and receive diversity. Describe how ea.pdf
Compare and contrast transmit and receive diversity. Describe how ea.pdf
poblettesedanoree498
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
poblettesedanoree498
 
Blood in the femoral artery will flow into what artery next Bl.pdf
Blood in the femoral artery will flow into what artery next Bl.pdfBlood in the femoral artery will flow into what artery next Bl.pdf
Blood in the femoral artery will flow into what artery next Bl.pdf
poblettesedanoree498
 
Assume that 96 of ticket holders show up for an airline flight. If .pdf
Assume that 96 of ticket holders show up for an airline flight. If .pdfAssume that 96 of ticket holders show up for an airline flight. If .pdf
Assume that 96 of ticket holders show up for an airline flight. If .pdf
poblettesedanoree498
 
Although some male crab spiders find and mate with adult female spide.pdf
Although some male crab spiders find and mate with adult female spide.pdfAlthough some male crab spiders find and mate with adult female spide.pdf
Although some male crab spiders find and mate with adult female spide.pdf
poblettesedanoree498
 
7. At October 1, Smithson Enterprises reported owners equity of $.pdf
7. At October 1, Smithson Enterprises reported owners equity of $.pdf7. At October 1, Smithson Enterprises reported owners equity of $.pdf
7. At October 1, Smithson Enterprises reported owners equity of $.pdf
poblettesedanoree498
 
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
poblettesedanoree498
 
Write a Java program that calculates the distance between two points.pdf
Write a Java program that calculates the distance between two points.pdfWrite a Java program that calculates the distance between two points.pdf
Write a Java program that calculates the distance between two points.pdf
poblettesedanoree498
 
Which of the following light waves has the most amount of energyH.pdf
Which of the following light waves has the most amount of energyH.pdfWhich of the following light waves has the most amount of energyH.pdf
Which of the following light waves has the most amount of energyH.pdf
poblettesedanoree498
 
What is the wobble position What is the consequence of its pres.pdf
What is the wobble position What is the consequence of its pres.pdfWhat is the wobble position What is the consequence of its pres.pdf
What is the wobble position What is the consequence of its pres.pdf
poblettesedanoree498
 
What is an advantage of having homologous chromosomes (compared to h.pdf
What is an advantage of having homologous chromosomes (compared to h.pdfWhat is an advantage of having homologous chromosomes (compared to h.pdf
What is an advantage of having homologous chromosomes (compared to h.pdf
poblettesedanoree498
 
What are oncogenic viruses Which of the following groups of viruses.pdf
What are oncogenic viruses  Which of the following groups of viruses.pdfWhat are oncogenic viruses  Which of the following groups of viruses.pdf
What are oncogenic viruses Which of the following groups of viruses.pdf
poblettesedanoree498
 
Unlike the biological species concept, the morphospecies concept rel.pdf
Unlike the biological species concept, the morphospecies concept rel.pdfUnlike the biological species concept, the morphospecies concept rel.pdf
Unlike the biological species concept, the morphospecies concept rel.pdf
poblettesedanoree498
 
1.) Which macronutrient do we consume in large amounts, but which we.pdf
1.) Which macronutrient do we consume in large amounts, but which we.pdf1.) Which macronutrient do we consume in large amounts, but which we.pdf
1.) Which macronutrient do we consume in large amounts, but which we.pdf
poblettesedanoree498
 
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
poblettesedanoree498
 
The systemic circuit delivers oxygenated blood to and returns blood t.pdf
The systemic circuit delivers oxygenated blood to and returns blood t.pdfThe systemic circuit delivers oxygenated blood to and returns blood t.pdf
The systemic circuit delivers oxygenated blood to and returns blood t.pdf
poblettesedanoree498
 

More from poblettesedanoree498 (20)

Give examples of two zoonotic diseases. Explain how these zoonotic d.pdf
Give examples of two zoonotic diseases. Explain how these zoonotic d.pdfGive examples of two zoonotic diseases. Explain how these zoonotic d.pdf
Give examples of two zoonotic diseases. Explain how these zoonotic d.pdf
 
Create the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfCreate the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdf
 
Describe different flow control valves with figures. Include referenc.pdf
Describe different flow control valves with figures. Include referenc.pdfDescribe different flow control valves with figures. Include referenc.pdf
Describe different flow control valves with figures. Include referenc.pdf
 
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdfConsider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
Consider a sample with data values of 10, 20, 12, 17, and 16.Compute.pdf
 
Compare and contrast transmit and receive diversity. Describe how ea.pdf
Compare and contrast transmit and receive diversity. Describe how ea.pdfCompare and contrast transmit and receive diversity. Describe how ea.pdf
Compare and contrast transmit and receive diversity. Describe how ea.pdf
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
Blood in the femoral artery will flow into what artery next Bl.pdf
Blood in the femoral artery will flow into what artery next Bl.pdfBlood in the femoral artery will flow into what artery next Bl.pdf
Blood in the femoral artery will flow into what artery next Bl.pdf
 
Assume that 96 of ticket holders show up for an airline flight. If .pdf
Assume that 96 of ticket holders show up for an airline flight. If .pdfAssume that 96 of ticket holders show up for an airline flight. If .pdf
Assume that 96 of ticket holders show up for an airline flight. If .pdf
 
Although some male crab spiders find and mate with adult female spide.pdf
Although some male crab spiders find and mate with adult female spide.pdfAlthough some male crab spiders find and mate with adult female spide.pdf
Although some male crab spiders find and mate with adult female spide.pdf
 
7. At October 1, Smithson Enterprises reported owners equity of $.pdf
7. At October 1, Smithson Enterprises reported owners equity of $.pdf7. At October 1, Smithson Enterprises reported owners equity of $.pdf
7. At October 1, Smithson Enterprises reported owners equity of $.pdf
 
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
5. A repeated measures analysis of variane shows, F(4,20)=14.56. How.pdf
 
Write a Java program that calculates the distance between two points.pdf
Write a Java program that calculates the distance between two points.pdfWrite a Java program that calculates the distance between two points.pdf
Write a Java program that calculates the distance between two points.pdf
 
Which of the following light waves has the most amount of energyH.pdf
Which of the following light waves has the most amount of energyH.pdfWhich of the following light waves has the most amount of energyH.pdf
Which of the following light waves has the most amount of energyH.pdf
 
What is the wobble position What is the consequence of its pres.pdf
What is the wobble position What is the consequence of its pres.pdfWhat is the wobble position What is the consequence of its pres.pdf
What is the wobble position What is the consequence of its pres.pdf
 
What is an advantage of having homologous chromosomes (compared to h.pdf
What is an advantage of having homologous chromosomes (compared to h.pdfWhat is an advantage of having homologous chromosomes (compared to h.pdf
What is an advantage of having homologous chromosomes (compared to h.pdf
 
What are oncogenic viruses Which of the following groups of viruses.pdf
What are oncogenic viruses  Which of the following groups of viruses.pdfWhat are oncogenic viruses  Which of the following groups of viruses.pdf
What are oncogenic viruses Which of the following groups of viruses.pdf
 
Unlike the biological species concept, the morphospecies concept rel.pdf
Unlike the biological species concept, the morphospecies concept rel.pdfUnlike the biological species concept, the morphospecies concept rel.pdf
Unlike the biological species concept, the morphospecies concept rel.pdf
 
1.) Which macronutrient do we consume in large amounts, but which we.pdf
1.) Which macronutrient do we consume in large amounts, but which we.pdf1.) Which macronutrient do we consume in large amounts, but which we.pdf
1.) Which macronutrient do we consume in large amounts, but which we.pdf
 
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
11.1.2 Entered Answer Preview 28 28 128 128 At least one of the an.pdf
 
The systemic circuit delivers oxygenated blood to and returns blood t.pdf
The systemic circuit delivers oxygenated blood to and returns blood t.pdfThe systemic circuit delivers oxygenated blood to and returns blood t.pdf
The systemic circuit delivers oxygenated blood to and returns blood t.pdf
 

Recently uploaded

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
 
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
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
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
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
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
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
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
 
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
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
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
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
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
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
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)

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...
 
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
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
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
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
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
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
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
 
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
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
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
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
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.
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
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
 

–PLS write program in c++ thanxLinked List Sorting and Reversing.pdf

  • 1. –PLS write program in c++ thanx Linked List Sorting and Reversing Write a C++ using your own linked list class to manage a list of string elements. Besides the basic operations expected of a linked list (add an element, remove an element, check for empty list, report size (number) of elements in the list, and print out the content of the list), the linked list class also needs to have a method called sort() and a method called reverse() the manipulate the string elements. The sort method rearranges the elements in the list so they are sorted in alphabetical order. The reverse method reverses the order of the elements of the list. Do NOT use recursion to implement either of these operations. pls write program in c++ thanx Solution #include #include using namespace std; class Node{ //class node public: string data; Node* next; void SetData(string aData) { data = aData; }; void SetNext(Node* aNext) { next = aNext; }; }; class List{ //class list Node *head; public: List() { head = NULL; }; void addElement(string data); void removeElement(string data); int isEmpty(Node* temp); int size(); void print(); void sort(); void reverse();
  • 2. }; int List::isEmpty(Node* temp){ //method to check whether list is empty or not if(temp!=NULL) return 1; else return 0; } void List::addElement(string data){ //method to add Node* newNode=new Node(); newNode->SetData(data); newNode->SetNext(NULL); Node* temp=head; if(temp!=NULL) { while(temp->next!=NULL) {temp=temp->next;} temp->next=newNode; } else head=newNode; } void List::removeElement(string data){ //method for delete Node* temp=head; Node *prev=head; if(isEmpty(temp)==1) {//prev=temp; while(temp!=NULL) { if(temp->data==data) {prev->next=temp->next; temp->next=NULL; } else {prev=temp;
  • 3. temp=temp->next; } } } else cout<<"Nothing to delete as linked list is empty "<next; } } return count; } void List::print(){ //method for print Node* temp=head; if(isEmpty(temp)==1){ while(temp!=NULL) { cout<data<<" "; temp=temp->next; } } } int main() { List list; list.addElement("anshu"); list.addElement("anurag"); list.addElement("how"); list.addElement("are"); list.addElement("you?"); int count=list.size(); cout<<"size of the linked list= "<