Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Calls a selection sort on the list
- listNode* sort (listNode* head)
- {
- if(head->next == NULL)
- return head;
- listNode* sortLead = head;
- listNode* smallest = sortLead;
- listNode* curr = sortLead->next;
- while(sortLead->next != NULL)
- {
- while(curr != NULL)
- {
- if(curr->data->freq < smallest->data->freq)
- {
- swap(curr, smallest);
- }
- curr = curr->next;
- }
- swap(sortLead, smallest);
- sortLead = sortLead->next;
- smallest = sortLead;
- curr = sortLead->next;
- }
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement