Question
I need this in c programming assignment is given and also code is given you just have to code the lines where it says TODO
I need this in c programming
assignment is given and also code is given you just have to
code the lines where it says TODO here
please edit the code that i have given and please send me screenshot of the output as well
please only edit this below code shown. any other form will not work
#include
void display(); void insert(int); void delete(int);
typedef struct node { int value; struct node *next; struct node *prev; } node;
node* head = NULL; node* tail = NULL;
/* * DO NOT MODIFY THE MAIN FUNCTION */ int main() { int n, task; while (scanf("%d %d", &n, &task) == 2) { if (n == 0 && task == 0) { display(); break; } else if (task == 1) { insert(n); display(); } else if (task == -1) { delete(n); display(); } else { continue; } } return 0; }
/* * This function inserts new value into the list. */ void insert(int value) { // TODO }
/* * This function deletes values from the list. */ void delete(int value) { // TODO }
/* * This function displays all list elements. */ void display() { node* curr_node = head; printf("The list: "); while (curr_node) { printf("%d ", curr_node->value); curr_node = curr_node->next; } printf(" ");
Sorted Double Linked List In this lab, we write a program mylist.c that will read input from the user and maintain a sorted double linked list We need to support two operations: Insertion and Deletion. The format of the input is "Value Operation". For example, if the user inputs "5 1", it means value 5 needs to be inserted into the list. Here the number 1 indicates the insertion operation If the user inputs"4 -1", it means the value 4 needs to be deleted from the list. Here the number -1 indicates the deletion operation. If there are no 4 in the list, print "Does not exist!". If there are multiple instances of 4, delete all instances of 4 from the list After each operation, we need to print the content of the list Once user input "0 0", Sample output the program prints the content of the list and terminates mylist 5 1 The list: 5 2 1 The list: 25 4 1 The list: 2 45 4-1 Th list: 25 The list: 25 mylist-c x FincludeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started