Sunday, September 25, 2011

Linked List is a palindrome or not

Question: Write a program to check if the given linked list is a palindrome or not

METHOD 1 (using recursion)


METHOD 2 (Using Stack)




  • Get the middle of the linked list.

  • Push the elements into the stack till the middle of the linked list

  • Compare the top of the stack and second half.

No comments: