Sort linked list

Node *MoveMinToStart(Node *aHead)
{
if(aHead == NULL or aHead->next == NULL)
return aHead;
Node *PrevMin = NULL,*Cur=aHead,*Prev=NULL,*Min=NULL;
while(Cur){
if(Min == NULL or Min->Value > Cur->Value){
Min = Cur;
PrevMin = Prev;
}
Prev = Cur;
Cur = Cur->next;
}
if(PrevMin == NULL)

Leave a Reply

Your email address will not be published. Required fields are marked *