Question: C++ Linked List Insertion program You will write a function that will use the Insertion Sort technique to sort values in a linked list. The

C++ Linked List Insertion program You will write a function that will use the Insertion Sort technique to sort values in a linked list. The basic idea is that you will make a temporary link list. You will start with the first node in your unsorted linked list and insert it into the temporary link list (after the head node with the value 0). Next, you will focus on the second node in your unsorted linked list and insert it into the correct position in the temporary link list. Next, you focus on the third node in your unsorted linked list and insert it into the correct position in the temporary link list. Repeat this process until you have gone through all the nodes in your unsorted linked list. Conceptually, your unsorted linked list is becoming one node smaller in each iteration and your temporary link list gains one node. The key thing to keep in mind is that you are not creating new nodes in the InsertionSort function, you are just rewiring pointers. Therefore, if you start with the head node of the temporary link list and traverse through by following the next pointer, the values will print out in sorted order. That is why at the end, we assign the temporary lists head pointer to the head pointer of the original list.

Outline of code: https://pastebin.com/yFExRuXK

Please use the template, and only do the insertionSort method, with no additional variables other than the ones listed. Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!