remove duplicates from sorted linked list Get link Facebook X Pinterest Email Other Apps By Admin - April 01, 2011 Write a C program to remove duplicates from a sorted linked list. Get link Facebook X Pinterest Email Other Apps Comments AnkitApril 4, 2011 at 1:42 PMvoid remove_duplicates_from_sorted_list(struct node* head){ if(head->next==NULL) return; struct node* current=head->next; struct node* previous=head; while(current!=NULL) { if(current->data==previous->data) { previous->next=current->next; delete(current); current=previous->next; } else { previous=current; current=current->next; } } }ReplyDeleteRepliesReplyAdminApril 4, 2011 at 2:09 PM@ankit yeah correct...ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
void remove_duplicates_from_sorted_list(struct node* head)
ReplyDelete{
if(head->next==NULL)
return;
struct node* current=head->next;
struct node* previous=head;
while(current!=NULL)
{
if(current->data==previous->data)
{
previous->next=current->next;
delete(current);
current=previous->next;
}
else
{
previous=current;
current=current->next;
}
}
}
@ankit yeah correct...
ReplyDelete