Question: Write code to check if a linked list is a palindrome. The list is made of characters. One way to accomplish this task is by

Write code to check if a linked list is a palindrome. The list is made of characters. One way to accomplish this task is by reversing the original list and comparing the two lists to be the same. To do so, write a function called compare with the following signature. int compare(NodePtr s1, NodePtr s2); Your function should traverse the lists beginning with s1 and s2. At each node in the lists, return a -1 if the node values are not equal. If the node values are equal, move the next node of both lists. In the main method, read in a series of values. Create a second reversed list. Now compare the original list and the reversed list to see if they are equal. If they are, print Palindrome! Using C

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!