Question: #include #include typedef struct node{ int key; struct node* next; } node_t; typedef node_t* node_ptr; void main() { node_ptr p = NULL; node_ptr listhead =

 #include #include typedef struct node{ int key; struct node* next; }

#include

#include

typedef struct node{

int key;

struct node* next;

} node_t;

typedef node_t* node_ptr;

void main()

{

node_ptr p = NULL;

node_ptr listhead = NULL;

/**

* FILL THE GAP:

* Create a listhead with key = 1,2,3,...,10

* Make sure next pointer is pointing to the

* next node

*/

/**

* FILL THE GAP:

* Delete node with key 5 6 and 7 in that order

*/

/**

* FILL THE GAP:

* Insert a new node with key 6

*/

/**

* Traverse the list and print the key

*/

p = listhead;

if(p==NULL)

{

printf("List empty ");

return;

}

/* traverse and print key */

while( p->next !=NULL)

{

printf("%d ", p->key);

p = p->next;

}

printf("%d ",p->key);

}

Your Code 1 #include #include 4 typedef struct node int key; struct node* next; 7 node.t; 9 typedef node_t* node_ptr; 10 11 void mainO 12- 13 14 15 16 17 18 19 20 21 node_ptr p NULL; node_ptr listhead NULL; FILL THE GAP * Create a listhead with key 1,2,3, , 10 Make sure next pointer is pointing to the * next node 23 24 25 26 27 28 29 30 31 32 FILL THE GAP * Delete node with key 5 6 and 7 in that order k* FILL THE GAP: *Insert a new node with key 6 34 35 36 38 39 40 41 42 * Traverse the list and print the key pisthead; if(p=-NULL) 44 45 46 47 48 49 50 51 52 53 54 printf("List empty "; return; /* traverse and print key whileC p->next !-NULL) printf("%d ", P -p->next; p->key); printf("%d " , p->key) ; 56 57

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!