Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 . Read a phrase and determine whether it is a palindrome or not. Write a c + + program to do the following: a

2. Read a phrase and determine whether it is a palindrome or not. Write a c++program to do the following:
a. Read the phrase character-by-character and store each letters or digits (use isalnum function) into a linked list pointed by listOriginal
b. Find the middle of the listOriginal
c. Reverse the second half of the listOriginal (insert each element after the middle element in front of new list listRev and delete the element from the listOriginal.
d. Compare the new listOrginal with listRev to test the phrase for being a palindrome or not
Sample run:
Enter a phrase: Top Spot
Original list: TopSpotNULL
New original (half of the original): TopNULL
The second half in reverse order, listRev: topSNULL
The phrase is a palindrome ( character by character they are the same with extra S at the end. No matching for S because the number of characters is odd)
CONTINUE(y/n)? y
Enter a phrase: No!2332 on
Original list: No2332onNULL
New original(half of the original): No23NULL
The second half in reverse order :no23NULL
The phrase is a palindrome
CONTINUE(y/n)? n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books