Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { doubl.
Please help solve this in C++ So the program is working fin.pdf
1. Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { double number = stod ( term );
cout "List after inserting " number " " " endl; 1ist. Insert(number); PrintList(1ist); } // Read the input
line with numbers to remove getline (cin, inputLine); terms = spacesplit(inputLine); // Remove each
value for (auto term : terms) { double number = stod ( term ); cout "List after removing " number " "
" endl; 1ist. Remove(number); PrintList(1ist); } return ; } // Prints the sortedNumberList's contents,
in order from head to tail void PrintList(SortednumberList& list) { Node* node = 1ist. head; while
(node) { cout node->GetData( )"; node = node > GetNext () ; } cout end1; 3 // Splits a string at
each space character, adding each substring to the vector vector spacesplit(string source) { vector
=; for (size_t 1=0;1< source.length ();1++){ if (" " " source [1]){ result.push_back
(source.substr(start, 1 - start)); start =1+1 } } result. push_back(source .substr(start)); return result;
}Current file: SortedNumberList.h// Removes the node with the specified number value from the
2. List. Returns // true if the node is found and removed, false otherwise. bool Remove(double
number) { // Return false if the list is empty if (head == nullptr) return false; // Else if the data to be
removed is at the head node else if (head->GetData ()== number) { // Reassign the node after the
head node as the head node head = head->GetNext ( ); // Unlink the previous head node from the
list head->setprevious(nullptr); return true; } // Else the node to be removed is somewhere after the
head node else { // Create a temporary node pointing to the head node Node *temp = head; //
Traverse the List till we find a matching data while (temp != nullptr && temp->getData() I= number)
temp = temp->GetNext (); // Return false if the number is not found in the list if (temp == nullptr)
return false; // If the node to be removed is the tail node else if (temp == tail) { // set the node
previous to the tail node as the tail node tail = tail->getPrevious (); // Unlink the previous tail node
from the list tail->setNext(nullptr); return true; } // else the node to be removed is somewhere in the
middle of the list else { // remove the temp node from the list temp->Getprevious () -
>SetNext(temp->GetNext()); temp->GetNext() ->SetPrevious (temp->Getprevious ()); free(temp);
return true; 3 } 3 Run your program as often as you'd like, before submitting for grading. Below,
type any needed input values in the first box, then click Run program and observe the program's
output in the second box.More insertion and removal (negative numbers, removal until list is
empty, and so on) Returned unexpected error code (11) PASS: Removing 100 yields an empty
list. PASS: Inserting 100 yields (100) PASS: Inserting 200 yields (100,200) PASS: Inserting -77.5
yields (77.5,100,200) PASS: Inserting 22.25 yields (77.5,22.25,100,200) PASS: Inserting -150
yields (150,77.5,22.25,100,200) PASS: Inserting 500 yields (150,77.5,22.25,100,200,500) PASS:
Removing -150 yields (77.5,22.25,100,200,500) PASS: Removing 500 yields (77.5,22.25,100,200)
PASS: Removing -77.5 yields (22.25,100,200) PASS: Removing 200 yields (22.25,100) PASS:
Removing 22.25 yields (100)