give a node address then we deleted now
i solve the question the question
but someone give suggestion code is
void delete(node *n)
n=(n->next);
i dont understand what is meaning this code
Geeksforgeeks question
It basically means assigning n->next to n, that is let’s consider a node n, it’s previous node as prev, then in the next of prev, n will be stored, putting
n=n->next
implies that instead of n, n->next will be placed in the next of prev, where earlier n was stored. so basically the next of prev will now point to the next of n instead of n, which means deletion of n.
The above code basically means:
void delete(node *n)
{
n->data = n->next->data;
n->next = n->next->next;
}
sir i know we write the above code in this ways
but asking about how can we write this code in this way