Please post your answer in comments if you have a better solution.
Keep linked list elements in reverse order. And print the linked list now. And do reverse again.
Like this:DisplayList(node){ if(node==NULL) return; DisplayList(node->next); Print(node->data);}
Keep linked list elements in reverse order. And print the linked list now. And do reverse again.
ReplyDeleteLike this:
ReplyDeleteDisplayList(node)
{
if(node==NULL) return;
DisplayList(node->next);
Print(node->data);
}