struct node *p,*q,*r;
r=null;
p=head;
while(p)
{
q=p->next;
p->next=r;
r=p;
p=q;
}
head=p;
With recurtion :-)
list *tail;
list *reverse (list *head)
{
if (head->next == NULL)
{
tail = head;
return;
}else{
reverse (head->next);
head->next->next = head;
head->next = NULL;
}
}
No comments:
Post a Comment