Saturday, August 2, 2008

C Code for Removing duplicate nodes from linked list

void RemoveDuplicates ( NODE**head) {

NODE *pCurrent = *head;

if(pCurrent ==NULL)
return;
else {
while(pCurrent ->next !=NULL) {

if(pCurrent ->data == pCurrent ->next->data) {

NODE *nnext = pCurrent ->next->next;
free(pCurrent ->next);
pCurrent ->next = nnext;
}
else
pCurrent =pCurrent ->next;
}
}
}

No comments:

Your Title