This is for a school project.
Me and my friends have been working on this specific project and have been stuck for quite a few days on this.
We have these 2 structures...
typedef struct node{
long value;
struct node *next;
}Node;
typedef struct list{
Node *Node;
struct list *next;
struct list *prev;
}List;
The struct called node will be the linked list itself, I have to use this structure as a linked list.
The second structure called List can be pointers to nodes.
Using the first structure (and the second, if we so choose) we have to shell (insertion flavor) sort the linked list of integers.
We have tried 2 different methods, one is to brute force the sort by traversing the gap elements, determining if they need to be moved somewhere in the sorted section of the linked list, and traversing the linked list from the beginning until we find an element larger then it in the sorted section. This worked, but took too long to run (it is a data structures and algorithms course, so we have to take into account run time).
The method we want to implement involves using the second structure to point to elements spaced by gap according to shell sort, and then to sort those values in the linked list for the gap sequence.
We know how to generate the sequence, but can anyone give us some tips on implementing the algorithm?
We already have the standard linked list formed.
We figure we will need to make a list create function, and a list insert function, but after that we are lost on how to start it.
Any and all tips and comments are appreciated!!!! Thanks!
EDIT: I cannot use any arrays in this implementation, the project is about the analysis of linked-lists and comparing their use and speed to arrays.