Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!