Vamsi Pavan’s Place

When curiousity outbursts …..

Sort linked list

October 6th, 2006 · No Comments · Algorithms

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)

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

Tags:

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment