I need help with the programming segments below, so I can study for them...I showed my effort on trying to do them. However, I don't believe they are right. If someone can assist me with this, I will definitely appreciate it.
1. Determine if a word is a palindrome or not using queues
q.addQueue(v);
for (int i = q.front(); i < q.front(); i--)
{
for (int j = q.back(); i<q.back(); i++
{
if ( q.front() == q.back() )
{
cout<<"It is a palindrome"<<endl;
}
else
{
cout<<"It is not a palindrome"<<endl;
}
}
}
2. Return the last item of a queue leaving the queue unchanged
if (!p.QueueIsEmpty() )
{
p.deleteQueue(v);
}
p.addQueue(v);
cout<<v;
3. Replace every occurence of every (e) in a queue with an (x)
if (!s.QueueIsEmpty)
{
for (int i=q.front(); i<q.front(); i--)
{
for (int j=q.back(); i<q.back(); i++)
{
if (q.front() == 'e') || (q.back() == 'e')
{
q.addQueue(x);
}
}
}
4. Give the sum of the 1st 3 elements in a queue leaving the queue unchanged
if (q.QueueIsEmpty())
{
for (i = q.front(); i<q.front()-3; i--)
{
q.DeleteQueue(v)
s.AddQueue(v)
sum+=val;
}
for (int i =0; i<3; i++)
{
s.DeleteQueue(v);
q.AddQueue(v);
}
else
{
cout<<"It is empty"<<endl;
}
cout<<"Sum is "<<sum;
5. Reverse the elements in a queue
while (!s.QueueIsEmpty())
{
p.DeleteQueue(v);
}
p.AddQueue(v);
cout<<v<<" ";
6. Exchange the front 2 elements of a queue
p.DeleteQueue(v);
p.DeleteQueue(e);
p.AddQueue(v);
p.AddQueue(e);