Operation place insert an element x into sorted linear linked list structure. Where head points to a sorted list and x is an element to be inserted into its proper position within the list. void...


In this code the x is
int
...Please modify the

condition
if x will be
char
 ..


for(p=*head; p!=NULL &&x>p->info; p=p->next)


we should change only this:
x>p->info


 ( maybe we need to use the ASCII code?)




Operation place insert an element x into sorted linear linked list structure.<br>Where head points to a sorted list and x is an element to be inserted into its<br>proper position within the list.<br>void place(NODEPTR *head , int x)<br>{<br>NODEPTR p, q;<br>q= NULL;<br>for(p=*head; p!=NULL && x>p->info; p=p->next)<br>q= p;<br>if (q == NULL) /* insert x at the head of the list */<br>{p=getnode()<br>p->info=x;<br>p->next = head;<br>head=p;<br>}<br>Else{<br>p=getnode();<br>p->info=x;<br>p->next=q->next;<br>q->next=p;<br>}<br>}<br>

Extracted text: Operation place insert an element x into sorted linear linked list structure. Where head points to a sorted list and x is an element to be inserted into its proper position within the list. void place(NODEPTR *head , int x) { NODEPTR p, q; q= NULL; for(p=*head; p!=NULL && x>p->info; p=p->next) q= p; if (q == NULL) /* insert x at the head of the list */ {p=getnode() p->info=x; p->next = head; head=p; } Else{ p=getnode(); p->info=x; p->next=q->next; q->next=p; } }

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here