reverse a linked list Get link Facebook X Pinterest Email Other Apps By Admin - November 30, 2010 How can I reverse a linked list recursively with minimum number of temporary pointers Get link Facebook X Pinterest Email Other Apps Comments AdminNovember 30, 2010 at 12:08 AMstruct node* reverse(struct node *head){struct node *rest = head->next;if(rest == NULL)return head;rest = reverse(head->next);head->next->next = head;head->next = NULL;return rest;}ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
struct node* reverse(struct node *head)
ReplyDelete{
struct node *rest = head->next;
if(rest == NULL)
return head;
rest = reverse(head->next);
head->next->next = head;
head->next = NULL;
return rest;
}