Removex() routine deletes all nodes whose info field contains the value x. void removex(NODEPTR *head , int x) { NODEPTR p , q , save; int y; q=NULL; p=*head; while (p!=NULL) if (p->info == x)...


This code deletes all nodes whose info field contains the value x.



Please modify the code to delete the only first value of x : ( maybe we need to add one line )  ( do not care about yellow .. thank you )



Removex() routine deletes all nodes whose info field contains the value x.<br>void removex(NODEPTR *head , int x)<br>{ NODEPTR p , q , save;<br>int y;<br>q=NULL;<br>p=*head;<br>while (p!=NULL)<br>if (p->info == x)<br>{save=p;<br>p= p->next;<br>if (q==NULL) {<br>freenode(*head);<br>*head = p;<br>else {freenode(save);<br>q->next=p;}<br>}else<br>{q = p;<br>p=p->next;<br>}<br>}<br>

Extracted text: Removex() routine deletes all nodes whose info field contains the value x. void removex(NODEPTR *head , int x) { NODEPTR p , q , save; int y; q=NULL; p=*head; while (p!=NULL) if (p->info == x) {save=p; p= p->next; if (q==NULL) { freenode(*head); *head = p; else {freenode(save); q->next=p;} }else {q = p; p=p->next; } }

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here