Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Sort linked list C

void BubbledSort_linked_list(struct Node **head)
{
    Node * curr = *head;
    Node * next;
    int temp;

    while (curr && curr->next)
    {

        Node * next = curr->next;
        while (next)
        {
            if (curr->data > next->data)
            {
                std::swap(next->data, curr->data);
            }
            next = next->next;
        }
        curr = curr->next;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Sort #linked #list #C
ADD COMMENT
Topic
Name
8+5 =