Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 626 Bytes

File metadata and controls

25 lines (19 loc) · 626 Bytes
 Node* insertionSort(struct Node* head)
    {
        //code here
        
        Node* dummy=new Node(1000);
        
        while(head)
        {
            Node* next=head->next;
            Node* temp=dummy;
            
            while(temp->next && temp->next->data<head->data)
                temp=temp->next;
            
            head->next=temp->next;
            temp->next=head;
            head=next;
        }
        
        return dummy->next;
    }