Efficent recursive approarch to find reverse of a linked list.
struct node *reverse(struct node *head)
{
{
struct node *temp;
if(head->next==NULL)
return head;
if(head->next==NULL)
return head;
temp=reverse(head->next);
head->next->next=head;
head->next->next=head;
head->next=NULL;
return temp;
return temp;
}
No comments:
Post a Comment