This assignment consists of getting linked list and sorting it using Insertion.
I have completed the appending and printing part but having trouble to move past the sort.
This is what I have so far:
Can someone please guide me towards right direction. Thanks
void NumberList::InsertionSort()
{
NumberList temp;
ListNode *add;
ListNode *addNext;
ListNode *insert;
add = head->next;
while (head != nullptr/*stop when there is nothing left to sort in the original list*/)
{
/* Replace this comment with one line of code to assign a value to addNext */
/* Replace this comment with one line of code to assign a value to insert */
while( true/*stop when you are at the end of the temp list*/)
{
if(true/* use the > operator to determine when to break out of this inner while loop*/)
{
break;
}
/* Replace this comment with one line of code to assign a value to insert */
}
/* Replace this comment with one line of code to assign a value to add->next */
/* Replace this comment with one line of code to assign a value to insert->next */
/* Replace this comment with one line of code to assign a value to add */
}
delete head;
/* Replace this comment with one line of code to assign a value to head */
temp.head = NULL;
}