Details
Send the pointer to head(phead
) and head itself.
Recurse till next
of head
is not NULL.
Start popping the frames. If *phead == *head
, good to move to next frame-up.
Before moving up, move phead
to next
// Recursive function to check if linked list is palindrome or not
int checkPalindrome(struct Node** left, struct Node* right)
{
// base case
if (right == NULL)
return 1;
int res = checkPalindrome(left, right->next) &&
((*left)->data == right->data);
(*left) = (*left)->next;
return res;
}