PALINDROME LINKED LIST


Wrong output

CHANGED CODE: https://ide.codingblocks.com/s/323409

You have to check for all the elements in the linked list. Simply checking the head won’t be of any use because you are just checking one element.
Let the linked list be -> 1 2 3 1
It is not a palindrome.

https://ide.codingblocks.com/s/323409 Refer to this. I have compared all elements

but while after reversing the linked list original linked list is also changing

In line 31, remove ‘&’. Don’t pass it by reference.

https://ide.codingblocks.com/s/323409 No again INCORRECT output

Your build linked list function is wrong.


Please check this code and tell me if you are able to understand it.

I understood this one bu that is the issue in my logic

Insert function is correct i guess because before printing if we try revresing the linked list its showing correct output

Logic is more or less the same. Your linked list is not being made correctly. Approach this question step by step. First successfully make the linked list. Print it and check. Then move on to reversing it and check if its a palindrome.
And there is no need to pass by reference anywhere. You might end up changing the original linked list.