Write C Functions Search Insert Element Delete Elements Singly Doubly Linked List Q37148621

Write C functions to search, to insert an element, and to deleteelements in singly /doubly linked list


Solution


`Hey,

Note: Brother in case of any queries, just comment inbox I would be very happy to assist all your queries

/* Given a reference (pointer to pointer) to thehead of a list

   and an int, inserts a new node onthe front of the list. */

void push(struct Node** head_ref, intnew_data)

{

    /* 1. allocate node*/

    struct Node* new_node =(struct Node*) malloc(sizeof(struct Node));

   

    /* 2. put in the data*/

    new_node->data =new_data;

   

    /* 3. Make next of new nodeas head */

    new_node->next =(*head_ref);

   

    /* 4. move the head to pointto the new node */

    (*head_ref)    =new_node;

}

void

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.