I\'m writing a simple file for one of my classes that is a simple linked list activity and I need to sort a linked list.
This is my source code so far:
/
Well, This loop will only go once (in the good case):
while(tmpNxt != tmpPtr && tmpNxt->value < a){
tmp = a;
tmpPtr->value = tmpNxt->value;
tmpNxt->value = tmp;
tmpPtr = tmpPtr->next;
}
Since it's homework, just a hint: which is tmpNxt and which is tmpPtr after the first iteration?
another lines to look at are those:
tmpPtr = head;
tmpNxt = tmpNxt->next;
both examples explain why only the first two elements were replaced in your example.