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;
} 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
Step 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