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/jb2LaS52
Any help is appreciated. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started