Advertisement
drout

Reverse List

Feb 13th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1. Node *new_head = NULL;
  2.  
  3. void reverse_list( Node *head )
  4. {
  5.     Node *np = head->next;
  6.  
  7.     if( np )
  8.     {
  9.         if( np->next )
  10.         {
  11.             reverse_list( np );
  12.             head->next = NULL;
  13.         }
  14.         else
  15.             new_head = np;
  16.  
  17.         np->next = head;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement