I'm trying to sort:0, 2, 1, 5, 4, 3, 6, 8, 9, 7, in ascending order.
Doing: while (i != NULL) results in an error, with the nested while loop failing to execute.
So, I stick with, due to better results: while (i->next != NULL)
You could say I'm trying to do insrtion sort, after having success with selection sort.
Doing: while (i != NULL) results in an error, with the nested while loop failing to execute.
So, I stick with, due to better results: while (i->next != NULL)
Test with an empty list
Test with the first element out of order.
Second snip
1 2 3
while (j->next != NULL){
//code that does not modify `j' or `j->next'
}
The logic is way off. Do this auxiliar function void inorder_insert( listNode *begin, listNode *end, listNode *value );
that would insert the value in the list that goes from begin to end (that's sorted) in the place where it should be.
As you are not doing `selection sort', having a `min' variable is obfuscated.
The assignment requires the pre-existing nodes in the linked list to be re-arranged, by a sort function.
Selection/Insertion sort or whatever I don't care. My point is, I'm trying to get the algorithm to work using a break statement in the if statement.
I already, I got the algorithm to work perfectly, without a break statement, in my first post.
Now I'd like to learn how to get the algorithm to work using a break statement.
By the way in line 58, I have changed it to: i = head;