Advertisement
Guest User

Unflatten List

a guest
Aug 16th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. void unflattenList(Node *head, Node **tail){
  2.     recursiveUnflatten(head);
  3.  
  4.     Node *cur=head;
  5.    
  6.     while(cur->next)
  7.         cur=cur->next;
  8.    
  9.     *tail=cur;
  10. }
  11.  
  12. void recursiveUnflatten(Node *child){
  13.     Node *cur=child;
  14.    
  15.     while(cur){
  16.         if(cur->child){
  17.             //break link
  18.             ((cur->child)->prev)->next=NULL;
  19.             (cur->child)->prev=NULL;
  20.             //recursion
  21.             recursiveUnflatten(cur->child);
  22.         }
  23.         cur=cur->next;
  24.     }  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement