reverse doubly linked list
void reverse(struct node **head_ref){ struct node *temp = NULL; struct node *current = *head_ref; /* swap next and prev for all nodes of doubly linked list */ while (current != NULL) { temp = current->prev; current->prev = current->next; current->next = temp; current = current->prev; } /* Before changing head, check for the cases like empty list and list with only one node */ if(temp != NULL ) *head_ref = temp->prev;}
super.....
ReplyDelete