Question: Hello, I really need help writing a function that sorts a Linked List using SHELL SORT . It MUST BE SHELL SORTED . PLEASE WRITE
Hello, I really need help writing a function that sorts a Linked List using SHELL SORT. It MUST BE SHELL SORTED. PLEASE WRITE IN C. ONLY C. NO OTHER LANGUAGE. This function is part of a larger project, and I am struggling to write it. I know how to shell sort an array, but I am having trouble doing the same with a linkedlist.
This is the function:
typedef struct _Node {
long value;
struct _Node *next;
} Node;
Node *List_Shellsort(Node *list, double *n_comp)
{
}
*list is the list of nodes that need to be sorted. *list is already full of values (the size of the list varies). ALL THE VALUES IN *list ARE LONG INTS. *n_comp is the number of comparisons made during the shell sorting process. A comparison here is defined to be any comparison that involves the field value in the structure Node. This variable will be assigned a value during the sorting. It is currently zero. I am using a particular gap sequence for this sorting (1,2,3,4,6,9.... this is Pratt's gap sequence). I have already created another function that generates this sequence. You may use your own gap sequence to write this function if that is convenient.
Step by Step Solution
3.48 Rating (164 Votes )
There are 3 Steps involved in it
void ShellSort ifhead int ... View full answer
Get step-by-step solutions from verified subject matter experts
