CodingSkills4u - Know the Best
A site for interview questions and answers .
Tuesday, July 12, 2011
Simple C Program to reverse Singly LinkedList using recursion
Code:
void reverse(struct node** headRef)
{
struct node* first;
struct node* rest;
if (*headRef == NULL)
return;
first = *headRef;
rest = first->next;
if (rest == NULL) return;
reverse(&rest);
first->next->next = first;
first->next = NULL;
*headRef = rest;
}
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)