Question
//give the output of the following program and draw the link list. struct node{ int info; struct node *link; }; typedef struct node *nodePTR; void
//give the output of the following program and draw the link list.
struct node{ int info; struct node *link; }; typedef struct node *nodePTR; void insort(nodePTR*,struct Info); nodePTR getnode(); int main(void) { nodePTR p=NULL,head=NULL,save; inti;
for(i=0;i<3;i++) { insort (&head,i+5); } save=head; do{ printf("%d",save->info); save=save->link; }while(save!=NULL);
return0; } nodePTR getnode() { nodePTR q; q=(nodePTR)malloc(sizeof(struct node)); return q; } void insort(NODEPTR *head , int x) { NODEPTR p,q,r; q=NULL; for(p=*head; p!=NULL &&x>p->info; p=p->link) q=p; if(q=NULL) { p=getnode(); p->info=x; p->link=head; head=p; } else { r=getnode(); q->link=r; r->info=x; r->link=p; } }
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