What sorting algorithm is this?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-03-27T16:25:52Z Indexed on 2010/03/27 16:33 UTC
Read the original article Hit count: 381

Filed under:
|
|
|
|

Hi, I have a sorting algorithm as follows. My question is, which sorting algorithm is this? I thought it was bubble sort, but it does not do multiple runs. Any idea? Thanks!

//sorting in descending order
struct node
{
    int value;
    node* NEXT;
}
//Assume HEAD pointer denotes the first element in the //linked list
// only change the values…don’t have to change the //pointers

Sort( Node *Head)
{
    node* first,second,temp;
    first= Head;
    while(first!=null)
    {
        second=first->NEXT;
        while(second!=null)
        {
            if(first->value < second->value)
            {
                temp = new node();
                temp->value=first->value;
                first->value=second->value;
                second->value=temp->value;
                delete temp;
            }
            second=second->NEXT;
        }

        first=first->NEXT;
    }
}

© Stack Overflow or respective owner

Related posts about sorting

Related posts about c++