Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am using the Data Structure of LinkedList. Can you help me fixing this methods? When I put a sentence like: hello world this is
I am using the Data Structure of LinkedList. Can you help me fixing this methods? When I put a sentence like: hello world this is the output Pig latin: hello world
Pig Latin: oworlday. It is supposed to be ellohay orldway. C I will give like. template
void LinkedList::moveToEndNode& NewPtr
if NewPtr nullptr NewPtrgetNext nullptr
return;
Node temp NewPtr;
NewPtr NewPtrgetNext;
while tempgetNext nullptr
temp tempgetNext;
tempsetNextNewPtr;
NewPtr NewPtrgetNext;
tempsetNextnullptr;
template
void LinkedList::addCharNode& newPtr
Node temp newPtr;
while tempgetNext nullptr
temp tempgetNext;
tempsetNextnew Nodea; Fix the method call
temp tempgetNext;
tempsetNextnew Nodey; Fix the method call
template
string LinkedList::pigLatinconst string& cadena
Node newPtr nullptr;
Node curPtr nullptr;
for char letra : cadena
if letra
if newPtr nullptr
newPtr new Nodeletra;
curPtr newPtr;
else
curPtrsetNextnew Nodeletra;
curPtr curPtrgetNext;
else
moveToEndnewPtr;
addCharnewPtr;
moveToEndnewPtr;
addCharnewPtr;
string result "Pig Latin: ;
curPtr newPtr;
while curPtr nullptr
result curPtrgetItem;
curPtr curPtrgetNext;
cout result endl;
return result;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started