Computer Science, asked by pawan11781, 11 months ago

C code to check whether linked list is palindrom or not

Answers

Answered by harshitabharadwaj602
2

Answer:

here is :-

Explanation:

in this program, we need to check whether given singly linked list is a palindrome or not. A palindromic list is the one which is equivalent to the reverse of itself.

Program to determine whether a singly linked list is the palindrome

The list given in the above figure is a palindrome since it is equivalent to its reverse list, i.e., 1, 2, 3, 2, 1. To check whether a list is a palindrome, we traverse the list and check if any element from the starting half doesn't match with any element from the ending half, then we set the variable flag to false and break the loop.

In the last, if the flag is false, then the list is palindrome otherwise not. The algorithm to check whether a list is a palindrome or not is given below

Similar questions