Thursday, July 17, 2008

Reversing a Linked List


Node reverseLinkedList(Node list)
{
Node present, prev, t;
present = list;
prev = NULL;
while(present != NULL) {
t = present->next;
present->next = prev;
prev = present;
present = t;
}
return prev;
}

No comments:

Post a Comment