SOLVED:Linked list

In a linked list U have to delete the Node XXX , XXX->link and XXX->info is given

void delete ( NODE XXX ){
----fill u r code here----
}
ANSWER IS THERE IN COMMENTs ,still u can add ur answer .

3 comments:

sathish.kulal said...

i had this question in my google interview

Krupa said...

NODE *tmp = NULL;
//Incase x is the last node
if(x->next == NULL)
{
x = NULL;
}
else
{
tmp = x->next;
x->value = tmp->value;
x->next=tmp->next;
free(x) ;
}

sathish.kulal said...

Answer1 :

krupa's comment.