Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

#include #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 Finclude 2 #include 3 4 void display ); 5 void insert(int); 6 void delete (int); 8 9 typedef struct node f 10 int value 12 struct node next; struct node *prev; 14 node; 15 16 node* head = NULL; 17 node* tail = NULL; 18 19 20 /* 21 DO NOT MODIFY THE MAIN FUNCTION 22*/ 23 int main) 24 25 int n, task; while (scanf("%d %d", &n, &task) 2) { == 27 28 29 30 31 32 display (); break; else if (task1) insert(n); display (); 34 35 36 37 38 39 else if (task1) delete(n); display (); else t continue; 41 42

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

13. Identify the refusal of the return in Dances with Wolves.

Answered: 1 week ago