Linked List Insertion Sort
Need your guys's opinion.. do you think this would be a good algorithm for an insertion sort for a double linked list..?
be honest! :)
How is my syntax?
void insertion_sort(node* input)
node *temp = head_ptr; //Preserve head_ptr integrity right away
while((input->price < temp->price) && (temp != NULL)) //Traverse the list until you find out where
//user entered price is no longer greater than
temp = temp->next; //a previously entered price.. and return a
//pointer to the list location.
//temp should contain the location of the list just previous to one with a greater price
//This next block of code performs the insertion
input->next = temp->next; //Make the user entered node point to the next node in line
temp->next = input; //Make the current node point to the user entered node
input->prev = temp; //Make the user input node point back to the previous node
Any optimization or other suggestions == good :cool: