Cntb/Death_Error/C&C++/linked_list_deletion.c
struct Node * DeletewithValue(struct Node * head, int value) // Time complexity O(n)
{
    struct Node * p = head;
    struct Node * q = head->next;
    while (q->data != value && q->next != NULL)
    {
        p = p->next;
        q = q->next;
    }
    if(q->data == value){
        p->next = q->next;
        free(q);
    }
    else
    {
        printf("Value Not found!\n");
    }
    
    return head;
    
}
// Delete a node with a given value
Delete a node with a given value
Delete a node with a given value
struct Node * DeletewithValue(struct Node * head, int value) 
{
    struct Node * p = head;
    struct Node * q = head->next;
    while (q->data != value && q->next != NULL)
    {
        p = p->next;
        q = q->next;
    }
    if(q->data == value){
        p->next = q->next;
        free(q);
    }
    else
    {
        printf("Value Not found!\n");
    }
    return head;
}
struct Node * DeletewithValue ( struct Node * head , int value ) { struct Node * p = head ; struct Node * q = head -> next ; while ( q -> data != value && q -> next != NULL ) { p = p -> next ; q = q -> next ; } if ( q -> data == value ) { p -> next = q -> next ; free ( q ) ; } else { printf ( " \n " ) ; } return head ; }
Delete a node with a given value
Delete a node with a given value
// Time complexity O(n)