Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

review the program and in the space to the right of the code,show the position o

ID: 3659537 • Letter: R

Question

review the program and in the space to the right of the code,show the position of the reference and their progress through the sorting process,given the list:5,7,1,8 private void insert(SortNode node) { SortNode current; SortNopde previous=null; boolean done=false; if(list==null) list=node; else { current=list; while(!done) { if(current.value>node.value) { if(previous!=null) previous.next=node; else list=node; else node.next=current; done=true; } else if(current.next==null) { current.next=node; done=true; } else { previous=current; current.current.next; } } } } //sort the linked list using the insertion sort public void sort() { SortNode current=list; list=null; if(current==null) return; SortNode temp=current; current=current.next; temp.next=null; insert(temp); while(current!=null) { temp=current; current=current.next; temp.next=null; insert(temp); }

Explanation / Answer

#include #include struct link { int data; struct link *next; }; int i; int number ; struct link *start, *node, *previous, *new1, *counter; void doubly_link_sort() { printf(" Input the number of node we need to create: "); scanf("%d", &number ); start->next = NULL; /* Empty list */ node = start; /* Point to the start of the list */ /* CREATE A LINKED LIST */ for (i = 0; i next = (struct link* ) malloc(sizeof(struct link)); node = node->next; printf(" Input the first node: %d: ", i+1); scanf("%d", &node->data); node->next = NULL; } /* END OF CREATION */ /* SORTING THE LINK LIST START FROM HERE */ new1 = start; for(; new1->next != NULL; new1 = new1->next) { for(counter = new1->next; counter != NULL; counter = counter->next) { if(new1->data > counter->data) { int temp = new1->data; new1->data = counter->data; counter->data = temp; } } } /* END OF SORTING */ /* Display the list */ node = start->next; printf(" After sorting the list is as follows: "); while (node) { printf(" %d", node->data); node = node->next; } } /* Function main */ void main() { doubly_link_sort(); }