Question: Using linked lists on C++ need assistance in two functions, insertSorted and removeSorted. I am a bit stuck and not able to wrap my head
Using linked lists on C++
need assistance in two functions, insertSorted and removeSorted. I am a bit stuck and not able to wrap my head around this so well. With the insert sorted function, not allowed to use looping statements. Only change the List header for functions, source can be used whichever way to test.
insert directions : Function insertSorted() inserts a new entry into the sorted list as indicated below: Using a pointer to create a new node that contains the new entry: Node
remove directions:
The Function removeSorted() removes a given entry from the sorted list. If the list is empty, return false. (removal failed) Otherwise, you may use following statements to find a pointer: preNode=getNodeBefore(anEntry); If preNode=NULL, that means either the item in the first node of the list is greater than anEntry or the item in the first node of the list is equal to anEntry. If the item is greater than the anEntry, then return false (anEntry is not in the list). If the item is equal to the anEntry, remove the first node of the list. If preNode!=NULL, find following pointer: curNode=preNode->getNext(); If curNode==NULL or curNode->getItem()>anEntry, return false (anEntry is not in the list). If curNode->getItem()==anEntry, remove the node that curNode points to.
header: https://pastebin.com/Sp6Ve0Rb
header(node): https://pastebin.com/981LAp7L
source: https://pastebin.com/FnhXbEHt
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
