(Solved) : Write Set Functions Perform Either Insertion Deletion List Values Based User Input Provide Q37283756 . . .
Please do the following using C:
__________________________________________________________________________________

__________________________________________________________________________________

What to do Write a set of functions that: That will perform either an insertion or deletion into a list of values based on user input (you are provided with the main function that will perform the user input). Insertion should keep the list in ascending order! Complete the function to traverse and print out the list after each operation You are provided the driver program and the header file. You will need to implement all functions contained in the header file in a separate C file. What to submit I ask you to submit the following: . Your well-commented source code file files) A screen shot of a run of your program, running the driver on the user input of 1, then value of 12; 0, then value of 12; 1, then value of 8; then 2 to quit. Sample run of the program: Enter 0 to delete node, 1 to add node, 2 to quit. Enter data value to delete: List Values 15 16 20 25 /*末末末末末末末末末末末末末末末末末末末末末末末末末末末末末末*/ *This program tests the functions to insert and delete /*items in a linked list. #include #include #include <stdio.h> <stdlib.h> “linkedlist.h” – int main (void) /* Declare variables and function prototypes. int k-e, old, value; struct node *head, *next, *previous, *nw, **ptr_to_head-&head; /*Generate and print a linked list with five nodes */ head-(struct node )malloc (sizeof (struct node)); next head; for (k-1; k<-5; k++) next->data k*5; next->link-(struct node *)malloc(sizeof (struct node)); previous – next; next next->link; previous->link = NULL; print_list(head); insert or the list. */ Allow user to while (k != 2) delete nodes in printf(“Enter e to delete node, 1 to add node, 2 to quit. n”); scanf(“%d”,&k); if (k -e) printf(“Enter data value to delete: n”); scanf (“d”, &old); delete(ptr_to_head,old); print_list(head); else printf(“Enter data value to add: n”); scanf(“M”,&value); nw (struct node *)malloc (sizeof(struct nw->data value node)); insert(ptr to_head,nw); print_list(head) /* Exit program. / return e; /* Define structure to represent a node in a 1linked list.*/ struct node int data; struct node *link; /*This function returns a value of one if the linked list */ /* is empty. int empty(struct node *head); /* This function prints a linked list. void print_list(struct node *head); /*This function inserts a new node in a linked list. void insert (struct node **ptr to_head, struct node *nw); /* This function deletes a node form a linked list. void delete(struct node*ptr to head, int old) Show transcribed image text What to do Write a set of functions that: That will perform either an insertion or deletion into a list of values based on user input (you are provided with the main function that will perform the user input). Insertion should keep the list in ascending order! Complete the function to traverse and print out the list after each operation You are provided the driver program and the header file. You will need to implement all functions contained in the header file in a separate C file. What to submit I ask you to submit the following: . Your well-commented source code file files) A screen shot of a run of your program, running the driver on the user input of 1, then value of 12; 0, then value of 12; 1, then value of 8; then 2 to quit. Sample run of the program: Enter 0 to delete node, 1 to add node, 2 to quit. Enter data value to delete: List Values 15 16 20 25
/*末末末末末末末末末末末末末末末末末末末末末末末末末末末末末末*/ *This program tests the functions to insert and delete /*items in a linked list. #include #include #include “linkedlist.h” – int main (void) /* Declare variables and function prototypes. int k-e, old, value; struct node *head, *next, *previous, *nw, **ptr_to_head-&head; /*Generate and print a linked list with five nodes */ head-(struct node )malloc (sizeof (struct node)); next head; for (k-1; kdata k*5; next->link-(struct node *)malloc(sizeof (struct node)); previous – next; next next->link; previous->link = NULL; print_list(head); insert or the list. */ Allow user to while (k != 2) delete nodes in printf(“Enter e to delete node, 1 to add node, 2 to quit. n”); scanf(“%d”,&k); if (k -e) printf(“Enter data value to delete: n”); scanf (“d”, &old); delete(ptr_to_head,old); print_list(head); else printf(“Enter data value to add: n”); scanf(“M”,&value); nw (struct node *)malloc (sizeof(struct nw->data value node)); insert(ptr to_head,nw); print_list(head) /* Exit program. / return e;
/* Define structure to represent a node in a 1linked list.*/ struct node int data; struct node *link; /*This function returns a value of one if the linked list */ /* is empty. int empty(struct node *head); /* This function prints a linked list. void print_list(struct node *head); /*This function inserts a new node in a linked list. void insert (struct node **ptr to_head, struct node *nw); /* This function deletes a node form a linked list. void delete(struct node*ptr to head, int old)
Expert Answer
Answer to What to do Write a set of functions that: That will perform either an insertion or deletion into a list of values based …
OR