This is a classic linked list problem.Deleting a node from linked list given the data to be deleted.Inserting a node in a sorted linked list.I saw various versions of this and here is my version. Could you check and let me know if this code is efficient?void deletenode(struct node *&first, int data) {    struct node * current = first;// first will have the node after deletion    struct node * prev = (node *)malloc(sizeof(node));    while(current!=NULL)    {        if(current->data!=data)        {            prev=current;            current = current->next;        }        else        {            prev->next = current->next;            delete current;            break;        }    }}void insertinsortedlist(struct node *& first, int data){    struct node * current = first;// first will have the node after insertion    struct node * newnode = (node *)malloc(sizeof(node));    newnode->data = data;    struct node * temp = (node *)malloc(sizeof(node));    while(current)    {        if((current->data < data) && (current->next->data > data))        {            temp = current->next;            current->next = newnode;            newnode->next = temp;            break;        }        current = current->next;    }}
Deleting a linked list node
c++;linked list